diff options
author | Qiu Shumin <shumin.qiu@intel.com> | 2014-09-18 01:21:01 +0000 |
---|---|---|
committer | shenshushi <shenshushi@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-09-18 01:21:01 +0000 |
commit | 4b6b543e77f3237c63e691f35d0bb259ddc287b4 (patch) | |
tree | 75542b14fa185a4267468863aca52c32f22b7de4 /ShellPkg/Application/Shell/ShellProtocol.c | |
parent | 9d66ee4d177307ca59f08d242e592ec95a325d26 (diff) | |
download | edk2-platforms-4b6b543e77f3237c63e691f35d0bb259ddc287b4.tar.xz |
ShellPkg: Fix the support for command line comments.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Chris Phillips <chrisp@hp.com>
Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16126 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Application/Shell/ShellProtocol.c')
-rw-r--r-- | ShellPkg/Application/Shell/ShellProtocol.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index 692e42b737..11f5d481f9 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -1433,6 +1433,8 @@ InternalShellExecuteDevicePath( UINTN *ExitDataSizePtr;
CHAR16 *ImagePath;
UINTN Index;
+ CHAR16 *Walker;
+ CHAR16 *NewCmdLine;
// ExitDataSize is not OPTIONAL for gBS->BootServices, provide somewhere for
// it to be dumped if the caller doesn't want it.
@@ -1449,6 +1451,17 @@ InternalShellExecuteDevicePath( InitializeListHead(&OrigEnvs);
NewHandle = NULL;
+
+ NewCmdLine = AllocateCopyPool (StrSize (CommandLine), CommandLine);
+ if (NewCmdLine == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ for (Walker = NewCmdLine; Walker != NULL && *Walker != CHAR_NULL ; Walker++) {
+ if (*Walker == L'^' && *(Walker+1) == L'#') {
+ CopyMem(Walker, Walker+1, StrSize(Walker) - sizeof(Walker[0]));
+ }
+ }
//
// Load the image with:
@@ -1478,9 +1491,9 @@ InternalShellExecuteDevicePath( if (!EFI_ERROR(Status)) {
ASSERT(LoadedImage->LoadOptionsSize == 0);
- if (CommandLine != NULL) {
- LoadedImage->LoadOptionsSize = (UINT32)StrSize(CommandLine);
- LoadedImage->LoadOptions = (VOID*)CommandLine;
+ if (NewCmdLine != NULL) {
+ LoadedImage->LoadOptionsSize = (UINT32)StrSize(NewCmdLine);
+ LoadedImage->LoadOptions = (VOID*)NewCmdLine;
}
//
@@ -1499,7 +1512,7 @@ InternalShellExecuteDevicePath( ShellParamsProtocol.StdIn = ShellInfoObject.NewShellParametersProtocol->StdIn;
ShellParamsProtocol.StdOut = ShellInfoObject.NewShellParametersProtocol->StdOut;
ShellParamsProtocol.StdErr = ShellInfoObject.NewShellParametersProtocol->StdErr;
- Status = UpdateArgcArgv(&ShellParamsProtocol, CommandLine, NULL, NULL);
+ Status = UpdateArgcArgv(&ShellParamsProtocol, NewCmdLine, NULL, NULL);
ASSERT_EFI_ERROR(Status);
//
// Replace Argv[0] with the full path of the binary we're executing:
@@ -1578,6 +1591,8 @@ FreeAlloc: ASSERT_EFI_ERROR (CleanupStatus);
}
+ FreePool (NewCmdLine);
+
return(Status);
}
/**
|