diff options
Diffstat (limited to 'ShellPkg/Application/Shell')
-rw-r--r-- | ShellPkg/Application/Shell/Shell.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c index fa7201642a..056d66d09e 100644 --- a/ShellPkg/Application/Shell/Shell.c +++ b/ShellPkg/Application/Shell/Shell.c @@ -835,9 +835,13 @@ ProcessCommandLine( ShellInfoObject.ShellInitSettings.BitUnion.Bits.Exit = FALSE;
ShellInfoObject.ShellInitSettings.Delay = 5;
- // Start LoopVar at 1 to ignore Argv[0] which is the name of this binary
- // (probably "Shell.efi")
- for (LoopVar = 1 ; LoopVar < gEfiShellParametersProtocol->Argc ; LoopVar++) {
+ //
+ // Start LoopVar at 0 to parse only optional arguments at Argv[0]
+ // and parse other parameters from Argv[1]. This is for use case that
+ // UEFI Shell boot option is created, and OptionalData is provided
+ // that starts with shell command-line options.
+ //
+ for (LoopVar = 0 ; LoopVar < gEfiShellParametersProtocol->Argc ; LoopVar++) {
CurrentArg = gEfiShellParametersProtocol->Argv[LoopVar];
if (UnicodeCollation->StriColl (
UnicodeCollation,
@@ -925,6 +929,13 @@ ProcessCommandLine( );
return EFI_INVALID_PARAMETER;
} else {
+ //
+ // First argument should be Shell.efi image name
+ //
+ if (LoopVar == 0) {
+ continue;
+ }
+
ShellInfoObject.ShellInitSettings.FileName = AllocateZeroPool(StrSize(CurrentArg));
if (ShellInfoObject.ShellInitSettings.FileName == NULL) {
return (EFI_OUT_OF_RESOURCES);
|