2 Main file for exit shell level 1 function.
4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
5 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include "UefiShellLevel1CommandsLib.h"
12 STATIC CONST SHELL_PARAM_ITEM ParamList
[] = {
18 Function for 'exit' command.
20 @param[in] ImageHandle Handle to the Image (NULL if Internal).
21 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
26 IN EFI_HANDLE ImageHandle
,
27 IN EFI_SYSTEM_TABLE
*SystemTable
33 SHELL_STATUS ShellStatus
;
37 ShellStatus
= SHELL_SUCCESS
;
40 // initialize the shell lib (we must be in non-auto-init...)
42 Status
= ShellInitialize ();
43 ASSERT_EFI_ERROR (Status
);
45 Status
= CommandInit ();
46 ASSERT_EFI_ERROR (Status
);
49 // parse the command line
51 Status
= ShellCommandLineParse (ParamList
, &Package
, &ProblemParam
, TRUE
);
52 if (EFI_ERROR (Status
)) {
53 if ((Status
== EFI_VOLUME_CORRUPTED
) && (ProblemParam
!= NULL
)) {
54 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel1HiiHandle
, L
"exit", ProblemParam
);
55 FreePool (ProblemParam
);
56 ShellStatus
= SHELL_INVALID_PARAMETER
;
62 // return the specified error code
64 Return
= ShellCommandLineGetRawValue (Package
, 1);
66 Status
= ShellConvertStringToUint64 (Return
, &RetVal
, FALSE
, FALSE
);
67 if (EFI_ERROR (Status
)) {
68 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV
), gShellLevel1HiiHandle
, L
"exit", Return
);
69 ShellStatus
= SHELL_INVALID_PARAMETER
;
72 // If we are in a batch file and /b then pass TRUE otherwise false...
74 ShellCommandRegisterExit ((BOOLEAN
)(gEfiShellProtocol
->BatchIsActive () && ShellCommandLineGetFlag (Package
, L
"/b")), RetVal
);
76 ShellStatus
= SHELL_SUCCESS
;
79 // If we are in a batch file and /b then pass TRUE otherwise false...
81 ShellCommandRegisterExit ((BOOLEAN
)(gEfiShellProtocol
->BatchIsActive () && ShellCommandLineGetFlag (Package
, L
"/b")), 0);
83 ShellStatus
= SHELL_SUCCESS
;
86 ShellCommandLineFreeVarList (Package
);