2 Main file for Shift shell level 1 function.
4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "UefiShellLevel1CommandsLib.h"
18 Function for 'shift' command.
20 @param[in] ImageHandle Handle to the Image (NULL if Internal).
21 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
25 ShellCommandRunShift (
26 IN EFI_HANDLE ImageHandle
,
27 IN EFI_SYSTEM_TABLE
*SystemTable
31 SCRIPT_FILE
*CurrentScriptFile
;
34 Status
= CommandInit();
35 ASSERT_EFI_ERROR(Status
);
37 if (!gEfiShellProtocol
->BatchIsActive()) {
38 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_NO_SCRIPT
), gShellLevel1HiiHandle
, L
"Shift");
39 return (SHELL_UNSUPPORTED
);
42 CurrentScriptFile
= ShellCommandGetCurrentScriptFile();
43 ASSERT(CurrentScriptFile
!= NULL
);
45 if (CurrentScriptFile
->Argc
< 2) {
46 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_FEW
), gShellLevel1HiiHandle
);
47 return (SHELL_UNSUPPORTED
);
50 for (LoopVar
= 0 ; LoopVar
< CurrentScriptFile
->Argc
; LoopVar
++) {
52 SHELL_FREE_NON_NULL(CurrentScriptFile
->Argv
[LoopVar
]);
54 if (LoopVar
< CurrentScriptFile
->Argc
-1) {
55 CurrentScriptFile
->Argv
[LoopVar
] = CurrentScriptFile
->Argv
[LoopVar
+1];
57 CurrentScriptFile
->Argv
[LoopVar
] = NULL
;
60 CurrentScriptFile
->Argc
--;
61 return (SHELL_SUCCESS
);