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
);\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