Skip to content

Commit

Permalink
ShellPkg: Add support for UEFI Shell 2.1 spec command line comments
Browse files Browse the repository at this point in the history
Example:
Shell> echo "You are ^#1!" # Testing echo
You are #1!

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chris Phillips <[email protected]>
Reviewed-by: Jaben Carsey <[email protected]>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15871 6f19259b-4bc3-4df7-8a09-765794883524
  • Loading branch information
Chris Phillips authored and jcarsey committed Aug 21, 2014
1 parent a29117b commit d41a79a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ShellPkg/Application/Shell/Shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -2457,6 +2457,24 @@ RunCommand(

TrimSpaces(&CleanOriginal);

//
// NULL out comments (leveraged from RunScriptFileHandle() ).
// The # character on a line is used to denote that all characters on the same line
// and to the right of the # are to be ignored by the shell.
// Afterward, again remove spaces, in case any were between the last command-parameter and '#'.
//
for (TempWalker = CleanOriginal; TempWalker != NULL && *TempWalker != CHAR_NULL; TempWalker++) {
if (*TempWalker == L'^') {
if (*(TempWalker + 1) == L'#') {
CopyMem (TempWalker, TempWalker + 1, StrSize (TempWalker) - sizeof (TempWalker[0]));
}
} else if (*TempWalker == L'#') {
*TempWalker = CHAR_NULL;
}
}

TrimSpaces(&CleanOriginal);

//
// Handle case that passed in command line is just 1 or more " " characters.
//
Expand Down

0 comments on commit d41a79a

Please sign in to comment.