VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellLevel1CommandsLib/Shift.c@ 108794

Last change on this file since 108794 was 108794, checked in by vboxsync, 2 weeks ago

Devices/EFI/FirmwareNew: Merge edk2-stable202502 from the vendor branch and make it build for the important platforms, bugref:4643

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1/** @file
2 Main file for Shift shell level 1 function.
3
4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
5 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9
10#include "UefiShellLevel1CommandsLib.h"
11
12/**
13 Function for 'shift' command.
14
15 @param[in] ImageHandle Handle to the Image (NULL if Internal).
16 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
17**/
18SHELL_STATUS
19EFIAPI
20ShellCommandRunShift (
21 IN EFI_HANDLE ImageHandle,
22 IN EFI_SYSTEM_TABLE *SystemTable
23 )
24{
25 EFI_STATUS Status;
26 SCRIPT_FILE *CurrentScriptFile;
27 UINTN LoopVar;
28
29 Status = CommandInit ();
30 ASSERT_EFI_ERROR (Status);
31
32 if (!gEfiShellProtocol->BatchIsActive ()) {
33 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"shift");
34 return (SHELL_UNSUPPORTED);
35 }
36
37 CurrentScriptFile = ShellCommandGetCurrentScriptFile ();
38 if (CurrentScriptFile == NULL) {
39 ASSERT (CurrentScriptFile != NULL);
40 return (SHELL_INVALID_PARAMETER);
41 }
42
43 if (CurrentScriptFile->Argc < 2) {
44 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"shift");
45 return (SHELL_UNSUPPORTED);
46 }
47
48 for (LoopVar = 0; LoopVar < CurrentScriptFile->Argc; LoopVar++) {
49 if (LoopVar == 0) {
50 SHELL_FREE_NON_NULL (CurrentScriptFile->Argv[LoopVar]);
51 }
52
53 if (LoopVar < CurrentScriptFile->Argc -1) {
54 CurrentScriptFile->Argv[LoopVar] = CurrentScriptFile->Argv[LoopVar+1];
55 } else {
56 CurrentScriptFile->Argv[LoopVar] = NULL;
57 }
58 }
59
60 CurrentScriptFile->Argc--;
61 return (SHELL_SUCCESS);
62}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette