From 3a3395f06b95ad5a0a78e23d293929e6809e09e5 Mon Sep 17 00:00:00 2001 From: Qiu Shumin Date: Wed, 17 Sep 2014 07:52:35 +0000 Subject: ShellPkg: Remove redundant quotes for command 'FOR' in Shell. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin Reviewed-by: Jaben Carsey git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16121 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Library/UefiShellLevel1CommandsLib/For.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'ShellPkg/Library') diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c index 4fdbdd051d..40f6677f9b 100644 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c +++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c @@ -294,6 +294,7 @@ ShellCommandRunFor ( SCRIPT_FILE *CurrentScriptFile; CHAR16 *ArgSet; CHAR16 *ArgSetWalker; + CHAR16 *Parameter; UINTN ArgSize; UINTN LoopVar; SHELL_FOR_INFO *Info; @@ -309,6 +310,7 @@ ShellCommandRunFor ( ShellStatus = SHELL_SUCCESS; ArgSetWalker = NULL; TempString = NULL; + Parameter = NULL; FirstPass = FALSE; // @@ -391,9 +393,15 @@ ShellCommandRunFor ( ShellCloseFileMetaArg(&FileList); } } else { - ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" \"", 0); - ArgSet = StrnCatGrow(&ArgSet, &ArgSize, gEfiShellParametersProtocol->Argv[LoopVar], 0); - ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0); + Parameter = gEfiShellParametersProtocol->Argv[LoopVar]; + if (Parameter[0] == L'\"' && Parameter[StrLen(Parameter)-1] == L'\"') { + ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0); + ArgSet = StrnCatGrow(&ArgSet, &ArgSize, Parameter, 0); + } else { + ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" \"", 0); + ArgSet = StrnCatGrow(&ArgSet, &ArgSize, Parameter, 0); + ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0); + } } } if (ArgSet == NULL) { @@ -692,12 +700,6 @@ ShellCommandRunFor ( InternalUpdateAliasOnList(Info->ReplacementName, TempString, &CurrentScriptFile->SubstList); Info->CurrentValue += StrLen(TempString); - if (Info->CurrentValue[0] == L'\"') { - Info->CurrentValue++; - } - while (Info->CurrentValue[0] == L' ') { - Info->CurrentValue++; - } if (Info->CurrentValue[0] == L'\"') { Info->CurrentValue++; } -- cgit v1.2.3