diff options
author | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-09-15 20:10:39 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-09-15 20:10:39 +0000 |
commit | b6b22b132ada04696a0f7481a12169808c3e2b3e (patch) | |
tree | f376a7fe380a769274e4676c2b0be914e115511c /ShellPkg | |
parent | a0248b09366c096be88a2fbaaff071b28b5d4ca5 (diff) | |
download | edk2-platforms-b6b22b132ada04696a0f7481a12169808c3e2b3e.tar.xz |
ShellPkg: Eliminate loss of high bits in return value from exit command on 64 bit platform.
submitted-by: jcarsey
reviewed-by: gookboy15a
reviewed-by: niruiyu
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12356 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r-- | ShellPkg/Application/Shell/Shell.c | 10 | ||||
-rw-r--r-- | ShellPkg/Include/Library/ShellCommandLib.h | 15 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c | 23 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c | 8 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c | 2 |
5 files changed, 49 insertions, 9 deletions
diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c index 3a5899f342..614c1e9595 100644 --- a/ShellPkg/Application/Shell/Shell.c +++ b/ShellPkg/Application/Shell/Shell.c @@ -475,6 +475,9 @@ UefiMain ( DEBUG_CODE(ShellInfoObject.ConsoleInfo = NULL;);
}
+ if (ShellCommandGetExit()) {
+ return ((EFI_STATUS)ShellCommandGetExitCode());
+ }
return (Status);
}
@@ -1622,6 +1625,7 @@ RunScriptFileHandle ( BOOLEAN PreCommandEchoState;
CONST CHAR16 *CurDir;
UINTN LineCount;
+ CHAR16 LeString[50];
ASSERT(!ShellCommandGetScriptExit());
@@ -1826,7 +1830,11 @@ RunScriptFileHandle ( }
if (ShellCommandGetScriptExit()) {
- ShellCommandRegisterExit(FALSE);
+ UnicodeSPrint(LeString, sizeof(LeString)*sizeof(LeString[0]), L"0x%Lx", ShellCommandGetExitCode());
+ DEBUG_CODE(InternalEfiShellSetEnv(L"DebugLasterror", LeString, TRUE););
+ InternalEfiShellSetEnv(L"Lasterror", LeString, TRUE);
+
+ ShellCommandRegisterExit(FALSE, 0);
Status = EFI_SUCCESS;
break;
}
diff --git a/ShellPkg/Include/Library/ShellCommandLib.h b/ShellPkg/Include/Library/ShellCommandLib.h index f453d22f3d..0f4f503410 100644 --- a/ShellPkg/Include/Library/ShellCommandLib.h +++ b/ShellPkg/Include/Library/ShellCommandLib.h @@ -340,11 +340,24 @@ ShellCommandSetEchoState ( Indicate that the current shell or script should exit.
@param[in] ScriptOnly TRUE if exiting a script; FALSE otherwise.
+ @param[in] ErrorCode The 64 bit error code to return.
**/
VOID
EFIAPI
ShellCommandRegisterExit (
- IN BOOLEAN ScriptOnly
+ IN BOOLEAN ScriptOnly,
+ IN CONST UINT64 ErrorCode
+ );
+
+/**
+ Retrieve the Exit code.
+
+ @return the value passed into RegisterExit.
+**/
+UINT64
+EFIAPI
+ShellCommandGetExitCode (
+ VOID
);
/**
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c index 2c1dcd3c13..971294ffd4 100644 --- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c +++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c @@ -26,6 +26,7 @@ STATIC SCRIPT_FILE_LIST mScriptList; STATIC ALIAS_LIST mAliasList;
STATIC BOOLEAN mEchoState;
STATIC BOOLEAN mExitRequested;
+STATIC UINT64 mExitCode;
STATIC BOOLEAN mExitScript;
STATIC CHAR16 *mProfileList;
STATIC UINTN mProfileListSize;
@@ -697,12 +698,14 @@ ShellCommandSetEchoState( /**
Indicate that the current shell or script should exit.
- @param[in] ScriptOnly TRUE if only exiting a script, FALSE othrwise.
+ @param[in] ScriptOnly TRUE if exiting a script; FALSE otherwise.
+ @param[in] ErrorCode The 64 bit error code to return.
**/
VOID
EFIAPI
ShellCommandRegisterExit (
- IN BOOLEAN ScriptOnly
+ IN BOOLEAN ScriptOnly,
+ IN CONST UINT64 ErrorCode
)
{
mExitRequested = (BOOLEAN)(!mExitRequested);
@@ -711,6 +714,7 @@ ShellCommandRegisterExit ( } else {
mExitScript = FALSE;
}
+ mExitCode = ErrorCode;
}
/**
@@ -729,6 +733,21 @@ ShellCommandGetExit ( }
/**
+ Retrieve the Exit code.
+
+ If ShellCommandGetExit returns FALSE than the return from this is undefined.
+
+ @return the value passed into RegisterExit.
+**/
+UINT64
+EFIAPI
+ShellCommandGetExitCode (
+ VOID
+ )
+{
+ return (mExitCode);
+}
+/**
Retrieve the Exit script indicator.
If ShellCommandGetExit returns FALSE than the return from this is undefined.
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c index 5620d023b1..3a3c59fa03 100644 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c +++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c @@ -77,16 +77,16 @@ ShellCommandRunExit ( //
// If we are in a batch file and /b then pass TRUE otherwise false...
//
- ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")));
+ ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")), RetVal);
- ShellStatus = (SHELL_STATUS)(RetVal);
+ ShellStatus = SHELL_SUCCESS;
}
} else {
// If we are in a batch file and /b then pass TRUE otherwise false...
//
- ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")));
+ ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")), 0);
- ShellStatus = (SHELL_STATUS)0;
+ ShellStatus = SHELL_SUCCESS;
}
ShellCommandLineFreeVarList (Package);
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c index d6ed793579..bedd591c0d 100644 --- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c +++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c @@ -84,7 +84,7 @@ ShellCommandRunPause ( }
if (EFI_ERROR(Status) || Resp == NULL || *Resp == ShellPromptResponseQuit) {
- ShellCommandRegisterExit(TRUE);
+ ShellCommandRegisterExit(TRUE, 0);
ShellStatus = SHELL_ABORTED;
}
|