]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Fix command-line parsing to start with Argv[0] when comparing passed-in...
authorChris Phillips <chrisp@hp.com>
Fri, 4 Apr 2014 13:45:36 +0000 (13:45 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 4 Apr 2014 13:45:36 +0000 (13:45 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chris Phillips <chrisp@hp.com>
Reviewed-By: Olivier Martin <Olivier.Martin@arm.com>
Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15432 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Application/Shell/Shell.c

index fa7201642a1cf07c22ea724b7cf8a3358cb2fca2..056d66d09ee6a539b76999e792839f802e8d1e80 100644 (file)
@@ -835,9 +835,13 @@ ProcessCommandLine(
   ShellInfoObject.ShellInitSettings.BitUnion.Bits.Exit         = FALSE;\r
   ShellInfoObject.ShellInitSettings.Delay = 5;\r
 \r
-  // Start LoopVar at 1 to ignore Argv[0] which is the name of this binary\r
-  // (probably "Shell.efi")\r
-  for (LoopVar = 1 ; LoopVar < gEfiShellParametersProtocol->Argc ; LoopVar++) {\r
+  //\r
+  // Start LoopVar at 0 to parse only optional arguments at Argv[0]\r
+  // and parse other parameters from Argv[1].  This is for use case that\r
+  // UEFI Shell boot option is created, and OptionalData is provided\r
+  // that starts with shell command-line options.\r
+  //\r
+  for (LoopVar = 0 ; LoopVar < gEfiShellParametersProtocol->Argc ; LoopVar++) {\r
     CurrentArg = gEfiShellParametersProtocol->Argv[LoopVar];\r
     if (UnicodeCollation->StriColl (\r
                             UnicodeCollation,\r
@@ -925,6 +929,13 @@ ProcessCommandLine(
         );\r
       return EFI_INVALID_PARAMETER;\r
     } else {\r
+      //\r
+      // First argument should be Shell.efi image name\r
+      //\r
+      if (LoopVar == 0) {\r
+        continue;\r
+      }\r
+\r
       ShellInfoObject.ShellInitSettings.FileName = AllocateZeroPool(StrSize(CurrentArg));\r
       if (ShellInfoObject.ShellInitSettings.FileName == NULL) {\r
         return (EFI_OUT_OF_RESOURCES);\r