]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
ShellPkg: Fix timezone command
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Ls.c
index 63af5eab18884d216110df720440073607260719..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
@@ -437,7 +441,7 @@ PrintLsOutput(
         }\r
       }\r
 \r
-      if (!Sfo && HeaderPrinted == FALSE) {\r
+      if (!Sfo && !HeaderPrinted) {\r
         PrintNonSfoHeader(CorrectedPath);\r
       }\r
       PrintFileInformation(Sfo, Node, &FileCount, &FileSize, &DirCount);\r
@@ -445,18 +449,21 @@ 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
     ShellCloseFileMetaArg(&ListHead);\r
     CorrectedPath[0] = CHAR_NULL;\r
     CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, RootPath, 0);\r
+    if (CorrectedPath == NULL) {\r
+      return SHELL_OUT_OF_RESOURCES;\r
+    }\r
     if (CorrectedPath[StrLen(CorrectedPath)-1] != L'\\'\r
       &&CorrectedPath[StrLen(CorrectedPath)-1] != L'/') {\r
       CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, L"\\",     0);\r
@@ -490,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
@@ -498,7 +512,7 @@ PrintLsOutput(
   SHELL_FREE_NON_NULL(CorrectedPath);\r
   ShellCloseFileMetaArg(&ListHead);\r
 \r
-  if (Found == NULL && FoundOne == FALSE) {\r
+  if (Found == NULL && !FoundOne) {\r
     return (SHELL_NOT_FOUND);\r
   }\r
 \r