]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
Add CTRL+C support for ‘ls’ command.
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Ls.c
index 64ce4ae2c02b9e6a3130bfc8ad7681bb4e3d055a..523096ac22d9e9cca2ec196e21aa4d7229d421e3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for ls shell level 2 function.\r
 \r
-  Copyright (c) 2013 Hewlett-Packard Development Company, L.P.\r
+  Copyright (c) 2013 - 2014, Hewlett-Packard Development Company, L.P.<BR>\r
   Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -408,6 +408,10 @@ PrintLsOutput(
         ; !IsNull(&ListHead->Link, &Node->Link)\r
         ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node->Link)\r
         ){\r
+      if (ShellGetExecutionBreakFlag ()) {\r
+        ShellStatus = SHELL_ABORTED;\r
+        break;\r
+      }\r
       ASSERT(Node != NULL);\r
       if (LongestPath < StrSize(Node->FullName)) {\r
         LongestPath = StrSize(Node->FullName);\r
@@ -445,12 +449,12 @@ PrintLsOutput(
       HeaderPrinted = TRUE;\r
     }\r
 \r
-    if (!Sfo) {\r
+    if (!Sfo && ShellStatus != SHELL_ABORTED) {\r
       PrintNonSfoFooter(FileCount, FileSize, DirCount);\r
     }\r
   }\r
 \r
-  if (Rec) {\r
+  if (Rec && ShellStatus != SHELL_ABORTED) {\r
     //\r
     // Re-Open all the files under the starting path for directories that didnt necessarily match our file filter\r
     //\r
@@ -493,6 +497,13 @@ PrintLsOutput(
             &FoundOne,\r
             Count,\r
             TimeZone);\r
+            \r
+          //\r
+          // Since it's running recursively, we have to break immediately when returned SHELL_ABORTED\r
+          //\r
+          if (ShellStatus == SHELL_ABORTED) {\r
+            break;\r
+          }\r
         }\r
       }\r
     }\r