Re: [edk2] [PATCH] ShellPkg: Don't strip positional parameters of quotation marks.

2015-11-06 Thread Carsey, Jaben
Reviewed-by: Jaben Carsey 

> -Original Message-
> From: Qiu, Shumin
> Sent: Friday, November 06, 2015 12:06 AM
> To: edk2-devel@lists.01.org
> Cc: Qiu, Shumin ; Carsey, Jaben
> 
> Subject: [PATCH] ShellPkg: Don't strip positional parameters of quotation
> marks.
> Importance: High
> 
> Per Shell SPEC 2.1 'Double-quotation marks that surround arguments are not
> stripped in positional parameters'. This patch makes Shell implementation to
> follow SPEC.
> 
> Cc: Jaben Carsey 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Qiu Shumin 
> ---
>  ShellPkg/Application/Shell/Shell.c | 30 ++---
>  ShellPkg/Application/Shell/Shell.h |  8 
>  .../Application/Shell/ShellParametersProtocol.c| 52 ---
> ---
>  .../Application/Shell/ShellParametersProtocol.h| 36 ++-
>  ShellPkg/Application/Shell/ShellProtocol.c |  2 +-
>  5 files changed, 80 insertions(+), 48 deletions(-)
> 
> diff --git a/ShellPkg/Application/Shell/Shell.c
> b/ShellPkg/Application/Shell/Shell.c
> index cb9d969..8af6647 100644
> --- a/ShellPkg/Application/Shell/Shell.c
> +++ b/ShellPkg/Application/Shell/Shell.c
> @@ -1863,7 +1863,7 @@ IsValidSplit(
>return (EFI_OUT_OF_RESOURCES);
>  }
>  TempWalker = (CHAR16*)Temp;
> -if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter,
> StrSize(CmdLine {
> +if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter,
> StrSize(CmdLine), TRUE))) {
>if (GetOperationType(FirstParameter) == Unknown_Invalid) {
>  ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND),
> ShellInfoObject.HiiHandle, FirstParameter);
>  SetLastError(SHELL_NOT_FOUND);
> @@ -2029,7 +2029,7 @@ DoHelpUpdate(
> 
>Walker = *CmdLine;
>while(Walker != NULL && *Walker != CHAR_NULL) {
> -if (!EFI_ERROR(GetNextParameter(&Walker, &CurrentParameter,
> StrSize(*CmdLine {
> +if (!EFI_ERROR(GetNextParameter(&Walker, &CurrentParameter,
> StrSize(*CmdLine), TRUE))) {
>if (StrStr(CurrentParameter, L"-?") == CurrentParameter) {
>  CurrentParameter[0] = L' ';
>  CurrentParameter[1] = L' ';
> @@ -2173,7 +2173,7 @@ RunInternalCommand(
>//
>// get the argc and argv updated for internal commands
>//
> -  Status = UpdateArgcArgv(ParamProtocol, NewCmdLine, &Argv, &Argc);
> +  Status = UpdateArgcArgv(ParamProtocol, NewCmdLine, Internal_Command,
> &Argv, &Argc);
>if (!EFI_ERROR(Status)) {
>  //
>  // Run the internal command.
> @@ -2520,7 +2520,7 @@ RunShellCommand(
>  return (EFI_OUT_OF_RESOURCES);
>}
>TempWalker = CleanOriginal;
> -  if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter,
> StrSize(CleanOriginal {
> +  if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter,
> StrSize(CleanOriginal), TRUE))) {
>  //
>  // Depending on the first parameter we change the behavior
>  //
> @@ -2767,34 +2767,34 @@ RunScriptFileHandle (
>if (NewScriptFile->Argv != NULL) {
>  switch (NewScriptFile->Argc) {
>default:
> -Status = ShellCopySearchAndReplace(CommandLine2,  CommandLine,
> PrintBuffSize, L"%9", NewScriptFile->Argv[9], FALSE, TRUE);
> +Status = ShellCopySearchAndReplace(CommandLine2,  CommandLine,
> PrintBuffSize, L"%9", NewScriptFile->Argv[9], FALSE, FALSE);
>  ASSERT_EFI_ERROR(Status);
>case 9:
> -Status = ShellCopySearchAndReplace(CommandLine,  CommandLine2,
> PrintBuffSize, L"%8", NewScriptFile->Argv[8], FALSE, TRUE);
> +Status = ShellCopySearchAndReplace(CommandLine,  CommandLine2,
> PrintBuffSize, L"%8", NewScriptFile->Argv[8], FALSE, FALSE);
>  ASSERT_EFI_ERROR(Status);
>case 8:
> -Status = ShellCopySearchAndReplace(CommandLine2,  CommandLine,
> PrintBuffSize, L"%7", NewScriptFile->Argv[7], FALSE, TRUE);
> +Status = ShellCopySearchAndReplace(CommandLine2,  CommandLine,
> PrintBuffSize, L"%7", NewScriptFile->Argv[7], FALSE, FALSE);
>  ASSERT_EFI_ERROR(Status);
>case 7:
> -Status = ShellCopySearchAndReplace(CommandLine,  CommandLine2,
> PrintBuffSize, L"%6", NewScriptFile->Argv[6], FALSE, TRUE);
> +Status = ShellCopySearchAndReplace(CommandLine,  CommandLine2,
> PrintBuffSize, L"%6", NewScriptFile->Argv[6], FALSE, FALSE);
>  ASSERT_EFI_ERROR(Status);
>case 6:
> -Status = ShellCopySearchAndReplace(CommandLine2,  CommandLine,
> PrintBuffSize, L"%5", NewScriptFile->Argv[5], FALSE, TRUE);
> +Status = ShellCopySearchAndReplace(CommandLine2,  CommandLine,
> PrintBuffSize, L"%5", NewScriptFile->Argv[5], FALSE, FALSE);
>  ASSERT_EFI_ERROR(Status);
>case 5:
> -Status = ShellCopySearchAndReplace(CommandLine,  CommandLine2,
> PrintBuffSize, L"%4", NewScriptFile->Argv[4], FALSE, TRUE);
> +Stat

[edk2] [PATCH] ShellPkg: Don't strip positional parameters of quotation marks.

2015-11-06 Thread Qiu Shumin
Per Shell SPEC 2.1 'Double-quotation marks that surround arguments are not 
stripped in positional parameters'. This patch makes Shell implementation to 
follow SPEC.

Cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin 
---
 ShellPkg/Application/Shell/Shell.c | 30 ++---
 ShellPkg/Application/Shell/Shell.h |  8 
 .../Application/Shell/ShellParametersProtocol.c| 52 --
 .../Application/Shell/ShellParametersProtocol.h| 36 ++-
 ShellPkg/Application/Shell/ShellProtocol.c |  2 +-
 5 files changed, 80 insertions(+), 48 deletions(-)

diff --git a/ShellPkg/Application/Shell/Shell.c 
b/ShellPkg/Application/Shell/Shell.c
index cb9d969..8af6647 100644
--- a/ShellPkg/Application/Shell/Shell.c
+++ b/ShellPkg/Application/Shell/Shell.c
@@ -1863,7 +1863,7 @@ IsValidSplit(
   return (EFI_OUT_OF_RESOURCES);
 }
 TempWalker = (CHAR16*)Temp;
-if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter, 
StrSize(CmdLine {
+if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter, 
StrSize(CmdLine), TRUE))) {
   if (GetOperationType(FirstParameter) == Unknown_Invalid) {
 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), 
ShellInfoObject.HiiHandle, FirstParameter);
 SetLastError(SHELL_NOT_FOUND);
@@ -2029,7 +2029,7 @@ DoHelpUpdate(
 
   Walker = *CmdLine;
   while(Walker != NULL && *Walker != CHAR_NULL) {
-if (!EFI_ERROR(GetNextParameter(&Walker, &CurrentParameter, 
StrSize(*CmdLine {
+if (!EFI_ERROR(GetNextParameter(&Walker, &CurrentParameter, 
StrSize(*CmdLine), TRUE))) {
   if (StrStr(CurrentParameter, L"-?") == CurrentParameter) {
 CurrentParameter[0] = L' ';
 CurrentParameter[1] = L' ';
@@ -2173,7 +2173,7 @@ RunInternalCommand(
   //
   // get the argc and argv updated for internal commands
   //
-  Status = UpdateArgcArgv(ParamProtocol, NewCmdLine, &Argv, &Argc);
+  Status = UpdateArgcArgv(ParamProtocol, NewCmdLine, Internal_Command, &Argv, 
&Argc);
   if (!EFI_ERROR(Status)) {
 //
 // Run the internal command.
@@ -2520,7 +2520,7 @@ RunShellCommand(
 return (EFI_OUT_OF_RESOURCES);
   }
   TempWalker = CleanOriginal;
-  if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter, 
StrSize(CleanOriginal {
+  if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter, 
StrSize(CleanOriginal), TRUE))) {
 //
 // Depending on the first parameter we change the behavior
 //
@@ -2767,34 +2767,34 @@ RunScriptFileHandle (
   if (NewScriptFile->Argv != NULL) {
 switch (NewScriptFile->Argc) {
   default:
-Status = ShellCopySearchAndReplace(CommandLine2,  CommandLine, 
PrintBuffSize, L"%9", NewScriptFile->Argv[9], FALSE, TRUE);
+Status = ShellCopySearchAndReplace(CommandLine2,  CommandLine, 
PrintBuffSize, L"%9", NewScriptFile->Argv[9], FALSE, FALSE);
 ASSERT_EFI_ERROR(Status);
   case 9:
-Status = ShellCopySearchAndReplace(CommandLine,  CommandLine2, 
PrintBuffSize, L"%8", NewScriptFile->Argv[8], FALSE, TRUE);
+Status = ShellCopySearchAndReplace(CommandLine,  CommandLine2, 
PrintBuffSize, L"%8", NewScriptFile->Argv[8], FALSE, FALSE);
 ASSERT_EFI_ERROR(Status);
   case 8:
-Status = ShellCopySearchAndReplace(CommandLine2,  CommandLine, 
PrintBuffSize, L"%7", NewScriptFile->Argv[7], FALSE, TRUE);
+Status = ShellCopySearchAndReplace(CommandLine2,  CommandLine, 
PrintBuffSize, L"%7", NewScriptFile->Argv[7], FALSE, FALSE);
 ASSERT_EFI_ERROR(Status);
   case 7:
-Status = ShellCopySearchAndReplace(CommandLine,  CommandLine2, 
PrintBuffSize, L"%6", NewScriptFile->Argv[6], FALSE, TRUE);
+Status = ShellCopySearchAndReplace(CommandLine,  CommandLine2, 
PrintBuffSize, L"%6", NewScriptFile->Argv[6], FALSE, FALSE);
 ASSERT_EFI_ERROR(Status);
   case 6:
-Status = ShellCopySearchAndReplace(CommandLine2,  CommandLine, 
PrintBuffSize, L"%5", NewScriptFile->Argv[5], FALSE, TRUE);
+Status = ShellCopySearchAndReplace(CommandLine2,  CommandLine, 
PrintBuffSize, L"%5", NewScriptFile->Argv[5], FALSE, FALSE);
 ASSERT_EFI_ERROR(Status);
   case 5:
-Status = ShellCopySearchAndReplace(CommandLine,  CommandLine2, 
PrintBuffSize, L"%4", NewScriptFile->Argv[4], FALSE, TRUE);
+Status = ShellCopySearchAndReplace(CommandLine,  CommandLine2, 
PrintBuffSize, L"%4", NewScriptFile->Argv[4], FALSE, FALSE);
 ASSERT_EFI_ERROR(Status);
   case 4:
-Status = ShellCopySearchAndReplace(CommandLine2,  CommandLine, 
PrintBuffSize, L"%3", NewScriptFile->Argv[3], FALSE, TRUE);
+Status = ShellCopySearchAndReplace(CommandLine2,  CommandLine, 
PrintBuffSize, L"%3", NewScriptFile->Argv[3], FALSE, FALSE);
 ASSERT_EF