summaryrefslogtreecommitdiff
path: root/ShellPkg/Application/Shell
diff options
context:
space:
mode:
authorJaben Carsey <jaben.carsey@intel.com>2013-12-13 18:18:27 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2013-12-13 18:18:27 +0000
commit680db511530e8b4e12545cad97cd344aba930201 (patch)
treee3deea26d471d1f2e70d1bafe2df5353341f2917 /ShellPkg/Application/Shell
parente94784c68de85297290b02153ac50c91cdf82b8c (diff)
downloadedk2-platforms-680db511530e8b4e12545cad97cd344aba930201.tar.xz
ShellPkg: Refactor Split/Pipe based command lines
This moves the initialization for handling command lines with pipe ‘|’ into a separate function. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14982 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Application/Shell')
-rw-r--r--ShellPkg/Application/Shell/Shell.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c
index ef757dec0f..b3dc8766ee 100644
--- a/ShellPkg/Application/Shell/Shell.c
+++ b/ShellPkg/Application/Shell/Shell.c
@@ -1589,6 +1589,36 @@ GetOperationType(
}
/**
+**/
+EFI_STATUS
+EFIAPI
+ProcessNewSplitCommandLine(
+ IN CONST CHAR16 *CmdLine
+ )
+{
+ SPLIT_LIST *Split;
+ EFI_STATUS Status;
+
+ Split = NULL;
+
+ //
+ // are we in an existing split???
+ //
+ if (!IsListEmpty(&ShellInfoObject.SplitList.Link)) {
+ Split = (SPLIT_LIST*)GetFirstNode(&ShellInfoObject.SplitList.Link);
+ }
+
+ if (Split == NULL) {
+ Status = RunSplitCommand(CmdLine, NULL, NULL);
+ } else {
+ Status = RunSplitCommand(CmdLine, Split->SplitStdIn, Split->SplitStdOut);
+ }
+ if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_INVALID_SPLIT), ShellInfoObject.HiiHandle, CmdLine);
+ }
+ return (Status);
+}
+/**
Function will process and run a command line.
This will determine if the command line represents an internal shell
@@ -1624,7 +1654,6 @@ RunCommand(
UINTN Count;
UINTN Count2;
CHAR16 *CleanOriginal;
- SPLIT_LIST *Split;
ASSERT(CmdLine != NULL);
if (StrLen(CmdLine) == 0) {
@@ -1636,7 +1665,6 @@ RunCommand(
DevPath = NULL;
Status = EFI_SUCCESS;
CleanOriginal = NULL;
- Split = NULL;
CleanOriginal = StrnCatGrow(&CleanOriginal, NULL, CmdLine, 0);
if (CleanOriginal == NULL) {
@@ -1672,21 +1700,7 @@ RunCommand(
// We dont do normal processing with a split command line (output from one command input to another)
//
if (ContainsSplit(CleanOriginal)) {
- //
- // are we in an existing split???
- //
- if (!IsListEmpty(&ShellInfoObject.SplitList.Link)) {
- Split = (SPLIT_LIST*)GetFirstNode(&ShellInfoObject.SplitList.Link);
- }
-
- if (Split == NULL) {
- Status = RunSplitCommand(CleanOriginal, NULL, NULL);
- } else {
- Status = RunSplitCommand(CleanOriginal, Split->SplitStdIn, Split->SplitStdOut);
- }
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_INVALID_SPLIT), ShellInfoObject.HiiHandle, CleanOriginal);
- }
+ Status = ProcessNewSplitCommandLine(CleanOriginal);
} else {
//