summaryrefslogtreecommitdiff
path: root/ShellPkg/Library
diff options
context:
space:
mode:
authorBrendan Jackman <Brendan.Jackman@arm.com>2014-01-24 22:31:07 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2014-01-24 22:31:07 +0000
commit3877d0f581536430fffe572ec3ceea29e0d50602 (patch)
treedf8a65c92cddb6beb06c55b00a5d3a600cf05a86 /ShellPkg/Library
parent708793148d0706c251e7971e55759f089874b471 (diff)
downloadedk2-platforms-3877d0f581536430fffe572ec3ceea29e0d50602.tar.xz
ShellPkg/UefiShellLib.c: Execute: Return a Command status even in the old shell
This means we can use ShellExecute without thinking which shell environment is in use. However it still isn't ideal: if mEfiShellEnvironment2->Execute returns EFI_INVALID_PARAMETER, we can't tell whether Execute() received an invalid parameter (e.g. ParentImageHandle was NULL), or whether we tried to execute a command with an invalid parameter (for example CommandLine "ls -hurdygurdy"). Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Brendan Jackman <Brendan.Jackman@arm.com> Reviewed-by: Olivier Martin <olivier.martin@arm.com> Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15183 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library')
-rw-r--r--ShellPkg/Library/UefiShellLib/UefiShellLib.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 12c6ea8380..e30e5c7dd1 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -1175,7 +1175,7 @@ ShellSetEnvironmentVariable (
The CommandLine is executed from the current working directory on the current
device.
- The EnvironmentVariables and Status parameters are ignored in a pre-UEFI Shell 2.0
+ The EnvironmentVariables pararemeter is ignored in a pre-UEFI Shell 2.0
environment. The values pointed to by the parameters will be unchanged by the
ShellExecute() function. The Output parameter has no effect in a
UEFI Shell 2.0 environment.
@@ -1203,6 +1203,7 @@ ShellExecute (
OUT EFI_STATUS *Status OPTIONAL
)
{
+ EFI_STATUS CmdStatus;
//
// Check for UEFI Shell 2.0 protocols
//
@@ -1221,16 +1222,29 @@ ShellExecute (
//
if (mEfiShellEnvironment2 != NULL) {
//
- // Call EFI Shell version (not using EnvironmentVariables or Status parameters)
+ // Call EFI Shell version.
// Due to oddity in the EFI shell we want to dereference the ParentHandle here
//
- return (mEfiShellEnvironment2->Execute(*ParentHandle,
+ CmdStatus = (mEfiShellEnvironment2->Execute(*ParentHandle,
CommandLine,
Output));
+ //
+ // No Status output parameter so just use the returned status
+ //
+ if (Status != NULL) {
+ *Status = CmdStatus;
+ }
+ //
+ // If there was an error, we can't tell if it was from the command or from
+ // the Execute() function, so we'll just assume the shell ran successfully
+ // and the error came from the command.
+ //
+ return EFI_SUCCESS;
}
return (EFI_UNSUPPORTED);
}
+
/**
Retreives the current directory path