]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Remove redundant quotes for command 'FOR' in Shell.
authorQiu Shumin <shumin.qiu@intel.com>
Wed, 17 Sep 2014 07:52:35 +0000 (07:52 +0000)
committershenshushi <shenshushi@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 17 Sep 2014 07:52:35 +0000 (07:52 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16121 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiShellLevel1CommandsLib/For.c

index 4fdbdd051d4c48b439b1b74c4c8b8fe37c79d1cb..40f6677f9baa59541f1ece5af9431d47a8b8ea8f 100644 (file)
@@ -294,6 +294,7 @@ ShellCommandRunFor (
   SCRIPT_FILE         *CurrentScriptFile;\r
   CHAR16              *ArgSet;\r
   CHAR16              *ArgSetWalker;\r
+  CHAR16              *Parameter;\r
   UINTN               ArgSize;\r
   UINTN               LoopVar;\r
   SHELL_FOR_INFO      *Info;\r
@@ -309,6 +310,7 @@ ShellCommandRunFor (
   ShellStatus         = SHELL_SUCCESS;\r
   ArgSetWalker        = NULL;\r
   TempString          = NULL;\r
+  Parameter           = NULL;\r
   FirstPass           = FALSE;\r
 \r
   //\r
@@ -391,9 +393,15 @@ ShellCommandRunFor (
             ShellCloseFileMetaArg(&FileList);\r
           }\r
         } else {\r
-          ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" \"", 0);\r
-          ArgSet = StrnCatGrow(&ArgSet, &ArgSize, gEfiShellParametersProtocol->Argv[LoopVar], 0);\r
-          ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);\r
+          Parameter = gEfiShellParametersProtocol->Argv[LoopVar];\r
+          if (Parameter[0] == L'\"' && Parameter[StrLen(Parameter)-1] == L'\"') {\r
+            ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0);\r
+            ArgSet = StrnCatGrow(&ArgSet, &ArgSize, Parameter, 0);\r
+          } else {\r
+            ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" \"", 0);\r
+            ArgSet = StrnCatGrow(&ArgSet, &ArgSize, Parameter, 0);\r
+            ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);\r
+          }\r
         }\r
       }\r
       if (ArgSet == NULL) {\r
@@ -692,12 +700,6 @@ ShellCommandRunFor (
           InternalUpdateAliasOnList(Info->ReplacementName, TempString, &CurrentScriptFile->SubstList);\r
           Info->CurrentValue += StrLen(TempString);\r
 \r
-          if (Info->CurrentValue[0] == L'\"') {\r
-            Info->CurrentValue++;\r
-          }\r
-          while (Info->CurrentValue[0] == L' ') {\r
-            Info->CurrentValue++;\r
-          }\r
           if (Info->CurrentValue[0] == L'\"') {\r
             Info->CurrentValue++;\r
           }\r