summaryrefslogtreecommitdiff
path: root/ShellPkg/Application/Shell/Shell.c
diff options
context:
space:
mode:
authorChris Phillips <chrisp@hp.com>2014-04-04 13:45:36 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2014-04-04 13:45:36 +0000
commite9d19a80afe61145433fe7f7f4c563c355c5c461 (patch)
tree4ce43eb3c84decd22915d532078927c15b40e62d /ShellPkg/Application/Shell/Shell.c
parent81514a8ad0a0456503663522536fec9395760311 (diff)
downloadedk2-platforms-e9d19a80afe61145433fe7f7f4c563c355c5c461.tar.xz
ShellPkg: Fix command-line parsing to start with Argv[0] when comparing passed-in options
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
Diffstat (limited to 'ShellPkg/Application/Shell/Shell.c')
-rw-r--r--ShellPkg/Application/Shell/Shell.c17
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);