2 Main file for Echo shell level 3 function.
4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
5 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved. <BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "UefiShellLevel3CommandsLib.h"
18 #include <Library/ShellLib.h>
20 STATIC CONST SHELL_PARAM_ITEM ParamList
[] = {
27 Function for 'echo' command.
29 @param[in] ImageHandle Handle to the Image (NULL if Internal).
30 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
35 IN EFI_HANDLE ImageHandle
,
36 IN EFI_SYSTEM_TABLE
*SystemTable
41 SHELL_STATUS ShellStatus
;
50 ShellStatus
= SHELL_SUCCESS
;
53 // initialize the shell lib (we must be in non-auto-init...)
55 Status
= ShellInitialize();
56 ASSERT_EFI_ERROR(Status
);
59 // parse the command line
61 Status
= ShellCommandLineParseEx (ParamList
, &Package
, &ProblemParam
, TRUE
, TRUE
);
62 if (EFI_ERROR(Status
)) {
63 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
64 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel3HiiHandle
, L
"echo", ProblemParam
);
65 FreePool(ProblemParam
);
66 ShellStatus
= SHELL_INVALID_PARAMETER
;
74 if (ShellCommandLineGetFlag(Package
, L
"-?")) {
77 if (ShellCommandLineGetFlag(Package
, L
"-on")) {
81 ShellCommandSetEchoState(TRUE
);
82 } else if (ShellCommandLineGetFlag(Package
, L
"-off")) {
86 ShellCommandSetEchoState(FALSE
);
87 } else if (ShellCommandLineGetRawValue(Package
, 1) == NULL
) {
89 // output its current state
91 if (ShellCommandGetEchoState()) {
92 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_ECHO_ON
), gShellLevel3HiiHandle
);
94 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_ECHO_OFF
), gShellLevel3HiiHandle
);
101 ; ShellCommandLineGetRawValue(Package
, ParamCount
) != NULL
104 StrnCatGrow(&PrintString
, &Size
, ShellCommandLineGetRawValue(Package
, ParamCount
), 0);
105 if (ShellCommandLineGetRawValue(Package
, ParamCount
+1) != NULL
) {
106 StrnCatGrow(&PrintString
, &Size
, L
" ", 0);
109 ShellPrintEx(-1, -1, L
"%s\r\n", PrintString
);
110 SHELL_FREE_NON_NULL(PrintString
);
114 // free the command line package
116 ShellCommandLineFreeVarList (Package
);
119 return (ShellStatus
);