2 Main file for Shift shell level 1 function.
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
10 #include "UefiShellLevel1CommandsLib.h"
13 Function for 'shift' command.
15 @param[in] ImageHandle Handle to the Image (NULL if Internal).
16 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
20 ShellCommandRunShift (
21 IN EFI_HANDLE ImageHandle
,
22 IN EFI_SYSTEM_TABLE
*SystemTable
26 SCRIPT_FILE
*CurrentScriptFile
;
29 Status
= CommandInit ();
30 ASSERT_EFI_ERROR (Status
);
32 if (!gEfiShellProtocol
->BatchIsActive ()) {
33 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_NO_SCRIPT
), gShellLevel1HiiHandle
, L
"shift");
34 return (SHELL_UNSUPPORTED
);
37 CurrentScriptFile
= ShellCommandGetCurrentScriptFile ();
38 ASSERT (CurrentScriptFile
!= NULL
);
40 if (CurrentScriptFile
->Argc
< 2) {
41 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_FEW
), gShellLevel1HiiHandle
, L
"shift");
42 return (SHELL_UNSUPPORTED
);
45 for (LoopVar
= 0; LoopVar
< CurrentScriptFile
->Argc
; LoopVar
++) {
47 SHELL_FREE_NON_NULL (CurrentScriptFile
->Argv
[LoopVar
]);
50 if (LoopVar
< CurrentScriptFile
->Argc
-1) {
51 CurrentScriptFile
->Argv
[LoopVar
] = CurrentScriptFile
->Argv
[LoopVar
+1];
53 CurrentScriptFile
->Argv
[LoopVar
] = NULL
;
57 CurrentScriptFile
->Argc
--;
58 return (SHELL_SUCCESS
);