]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: CTRL-C stops a running script at the same time
authorJaben Carsey <jaben.carsey@intel.com>
Thu, 19 Dec 2013 21:55:13 +0000 (21:55 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 19 Dec 2013 21:55:13 +0000 (21:55 +0000)
This makes CTRL-C stop a running script after trying to stop the command.  And adds comments to describe the behavior more clearly.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15008 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Application/Shell/Shell.c

index fe722e955448bd0c60d6901da4bf3f9d350e85fc..5e3af1d0565644add4095a1bb42a8288434cdc9f 100644 (file)
@@ -1840,8 +1840,19 @@ RunInternalCommand(
       // Pass thru the exitcode from the app.\r
       //\r
       if (ShellCommandGetExit()) {\r
+        //\r
+        // An Exit was requested ("exit" command), pass its value up.\r
+        //\r
         Status = CommandReturnedStatus;\r
-      } else if (CommandReturnedStatus != 0 && IsScriptOnlyCommand(FirstParameter)) {\r
+      } else if (CommandReturnedStatus != SHELL_SUCCESS && IsScriptOnlyCommand(FirstParameter)) {\r
+        //\r
+        // Always abort when a script only command fails for any reason\r
+        //\r
+        Status = EFI_ABORTED;\r
+      } else if (ShellCommandGetCurrentScriptFile() != NULL && CommandReturnedStatus == SHELL_ABORTED) {\r
+        //\r
+        // Abort when in a script and a command aborted\r
+        //\r
         Status = EFI_ABORTED;\r
       }\r
     }\r
@@ -1853,11 +1864,17 @@ RunInternalCommand(
   //\r
   RestoreArgcArgv(ParamProtocol, &Argv, &Argc);\r
 \r
-  if (ShellCommandGetCurrentScriptFile() != NULL &&  !IsScriptOnlyCommand(FirstParameter)) {\r
-    //\r
-    // if this is NOT a scipt only command return success so the script won't quit.\r
-    // prevent killing the script - this is the only place where we know the actual command name (after alias and variable replacement...)\r
-    //\r
+  //\r
+  // If a script is running and the command is not a scipt only command, then\r
+  // change return value to success so the script won't halt (unless aborted).\r
+  //\r
+  // Script only commands have to be able halt the script since the script will\r
+  // not operate if they are failing.\r
+  //\r
+  if ( ShellCommandGetCurrentScriptFile() != NULL\r
+    && !IsScriptOnlyCommand(FirstParameter)\r
+    && Status != EFI_ABORTED\r
+    ) {\r
     Status = EFI_SUCCESS;\r
   }\r
 \r