~ubuntu-branches/ubuntu/wily/edk2/wily

« back to all changes in this revision

Viewing changes to ShellPkg/Library/UefiShellLevel1CommandsLib/Shift.c

  • Committer: Package Import Robot
  • Author(s): Steve Langasek
  • Date: 2013-02-10 13:11:25 UTC
  • Revision ID: package-import@ubuntu.com-20130210131125-0zwkb8f8m4ecia4m
Tags: upstream-0~20121205.edae8d2d
ImportĀ upstreamĀ versionĀ 0~20121205.edae8d2d

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** @file
 
2
  Main file for Shift shell level 1 function.
 
3
 
 
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
 
9
 
 
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.
 
12
 
 
13
**/
 
14
 
 
15
#include "UefiShellLevel1CommandsLib.h"
 
16
 
 
17
/**
 
18
  Function for 'shift' command.
 
19
 
 
20
  @param[in] ImageHandle  Handle to the Image (NULL if Internal).
 
21
  @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
 
22
**/
 
23
SHELL_STATUS
 
24
EFIAPI
 
25
ShellCommandRunShift (
 
26
  IN EFI_HANDLE        ImageHandle,
 
27
  IN EFI_SYSTEM_TABLE  *SystemTable
 
28
  )
 
29
{
 
30
  EFI_STATUS          Status;
 
31
  SCRIPT_FILE         *CurrentScriptFile;
 
32
  UINTN               LoopVar;
 
33
 
 
34
  Status = CommandInit();
 
35
  ASSERT_EFI_ERROR(Status);
 
36
 
 
37
  if (!gEfiShellProtocol->BatchIsActive()) {
 
38
    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"Shift");
 
39
    return (SHELL_UNSUPPORTED);
 
40
  }
 
41
 
 
42
  CurrentScriptFile = ShellCommandGetCurrentScriptFile();
 
43
  ASSERT(CurrentScriptFile != NULL);
 
44
 
 
45
  if (CurrentScriptFile->Argc < 2) {
 
46
    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle);
 
47
    return (SHELL_UNSUPPORTED);
 
48
  }
 
49
 
 
50
  for (LoopVar = 0 ; LoopVar < CurrentScriptFile->Argc ; LoopVar++) {
 
51
    if (LoopVar == 0) {
 
52
      SHELL_FREE_NON_NULL(CurrentScriptFile->Argv[LoopVar]);
 
53
    }
 
54
    if (LoopVar < CurrentScriptFile->Argc -1) {
 
55
      CurrentScriptFile->Argv[LoopVar] = CurrentScriptFile->Argv[LoopVar+1];
 
56
    } else {
 
57
      CurrentScriptFile->Argv[LoopVar] = NULL;
 
58
    }
 
59
  }
 
60
  CurrentScriptFile->Argc--;
 
61
  return (SHELL_SUCCESS);
 
62
}
 
63