]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/UefiShellLib.c: Execute: Return a Command status even in the old shell
authorBrendan Jackman <Brendan.Jackman@arm.com>
Fri, 24 Jan 2014 22:31:07 +0000 (22:31 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 24 Jan 2014 22:31:07 +0000 (22:31 +0000)
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

ShellPkg/Library/UefiShellLib/UefiShellLib.c

index 12c6ea8380848ace7f5ca3be1b69d0c10461303b..e30e5c7dd14f03cf53b55a7ba97cdd99cae61596 100644 (file)
@@ -1175,7 +1175,7 @@ ShellSetEnvironmentVariable (
   The CommandLine is executed from the current working directory on the current\r
   device.\r
 \r
-  The EnvironmentVariables and Status parameters are ignored in a pre-UEFI Shell 2.0\r
+  The EnvironmentVariables pararemeter is ignored in a pre-UEFI Shell 2.0\r
   environment.  The values pointed to by the parameters will be unchanged by the\r
   ShellExecute() function.  The Output parameter has no effect in a\r
   UEFI Shell 2.0 environment.\r
@@ -1203,6 +1203,7 @@ ShellExecute (
   OUT EFI_STATUS                *Status OPTIONAL\r
   )\r
 {\r
+  EFI_STATUS                CmdStatus;\r
   //\r
   // Check for UEFI Shell 2.0 protocols\r
   //\r
@@ -1221,16 +1222,29 @@ ShellExecute (
   //\r
   if (mEfiShellEnvironment2 != NULL) {\r
     //\r
-    // Call EFI Shell version (not using EnvironmentVariables or Status parameters)\r
+    // Call EFI Shell version.\r
     // Due to oddity in the EFI shell we want to dereference the ParentHandle here\r
     //\r
-    return (mEfiShellEnvironment2->Execute(*ParentHandle,\r
+    CmdStatus = (mEfiShellEnvironment2->Execute(*ParentHandle,\r
                                           CommandLine,\r
                                           Output));\r
+    //\r
+    // No Status output parameter so just use the returned status\r
+    //\r
+    if (Status != NULL) {\r
+      *Status = CmdStatus;\r
+    }\r
+    //\r
+    // If there was an error, we can't tell if it was from the command or from\r
+    // the Execute() function, so we'll just assume the shell ran successfully\r
+    // and the error came from the command.\r
+    //\r
+    return EFI_SUCCESS;\r
   }\r
 \r
   return (EFI_UNSUPPORTED);\r
 }\r
+\r
 /**\r
   Retreives the current directory path\r
 \r