]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel3CommandsLib/Echo.c
ShellPkg: Clean up source files
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel3CommandsLib / Echo.c
index dc6bca0b8ad6541a5f8d838c73596b32508ecb42..a10edb2abd0085700024f4c9c4700c355ca204b6 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
   Main file for Echo shell level 3 function.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>\r
+  (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
+  Copyright (c) 2009 - 2018, 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
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -37,11 +38,15 @@ ShellCommandRunEcho (
 {\r
   EFI_STATUS          Status;\r
   LIST_ENTRY          *Package;\r
-//  CHAR16              *ProblemParam;\r
   SHELL_STATUS        ShellStatus;\r
   UINTN               ParamCount;\r
+  CHAR16              *ProblemParam;\r
+  UINTN               Size;\r
+  CHAR16              *PrintString;\r
 \r
-//  ProblemParam        = NULL;\r
+  Size                = 0;\r
+  ProblemParam        = NULL;\r
+  PrintString         = NULL;\r
   ShellStatus         = SHELL_SUCCESS;\r
 \r
   //\r
@@ -53,16 +58,16 @@ ShellCommandRunEcho (
   //\r
   // parse the command line\r
   //\r
-  Status = ShellCommandLineParseEx (ParamList, &Package, NULL, TRUE, TRUE);\r
-//  if (EFI_ERROR(Status)) {\r
-//    if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
-//      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);\r
-//      FreePool(ProblemParam);\r
-//      ShellStatus = SHELL_INVALID_PARAMETER;\r
-//    } else {\r
-//      ASSERT(FALSE);\r
-//    }\r
-//  } else {\r
+  Status = ShellCommandLineParseEx (ParamList, &Package, &ProblemParam, TRUE, TRUE);\r
+  if (EFI_ERROR(Status)) {\r
+    if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"echo", ProblemParam);\r
+      FreePool(ProblemParam);\r
+      ShellStatus = SHELL_INVALID_PARAMETER;\r
+    } else {\r
+      ASSERT(FALSE);\r
+    }\r
+  } else {\r
     //\r
     // check for "-?"\r
     //\r
@@ -96,20 +101,20 @@ ShellCommandRunEcho (
           ; ShellCommandLineGetRawValue(Package, ParamCount) != NULL\r
           ; ParamCount++\r
          ) {\r
+        StrnCatGrow(&PrintString, &Size, ShellCommandLineGetRawValue(Package, ParamCount), 0);\r
         if (ShellCommandLineGetRawValue(Package, ParamCount+1) != NULL) {\r
-          ShellPrintEx(-1, -1, L"%s ", ShellCommandLineGetRawValue(Package, ParamCount));\r
-        } else {\r
-          ShellPrintEx(-1, -1, L"%s", ShellCommandLineGetRawValue(Package, ParamCount));\r
+          StrnCatGrow(&PrintString, &Size, L" ", 0);\r
         }\r
       }\r
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF), gShellLevel3HiiHandle);\r
+      ShellPrintEx(-1, -1, L"%s\r\n", PrintString);\r
+      SHELL_FREE_NON_NULL(PrintString);\r
     }\r
 \r
     //\r
     // free the command line package\r
     //\r
     ShellCommandLineFreeVarList (Package);\r
-//  }\r
+  }\r
 \r
   return (ShellStatus);\r
 }\r