]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Make 'alias' can display a single alias name.
authorQiu Shumin <shumin.qiu@intel.com>
Wed, 6 Jan 2016 07:43:58 +0000 (07:43 +0000)
committershenshushi <shenshushi@Edk2>
Wed, 6 Jan 2016 07:43:58 +0000 (07:43 +0000)
When we run command "alias cat" Shell print out "alias: Too few arguments". This patch makes value of single alias name can be displayed.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19608 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiShellLevel3CommandsLib/Alias.c

index 1161746cc789380515192f6f9f56b811e7043533..bcd14c854104e3b2c84e40a545607f796403ee03 100644 (file)
@@ -2,7 +2,7 @@
   Main file for Alias shell level 3 function.\r
 \r
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. <BR>\r
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved. <BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -92,6 +92,8 @@ ShellCommandRunAlias (
   CONST CHAR16        *Param1;\r
   CONST CHAR16        *Param2;\r
   CHAR16              *CleanParam2;\r
+  CONST CHAR16        *ConstAliasVal;\r
+  BOOLEAN             Volatile;\r
 \r
   ProblemParam        = NULL;\r
   ShellStatus         = SHELL_SUCCESS;\r
@@ -165,8 +167,19 @@ ShellCommandRunAlias (
         }\r
       }\r
     } else if (ShellCommandLineGetCount(Package) == 2) {\r
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel3HiiHandle, L"alias");  \r
-      ShellStatus = SHELL_INVALID_PARAMETER;\r
+      //\r
+      // print out a single alias\r
+      //\r
+      ConstAliasVal = gEfiShellProtocol->GetAlias(Param1, &Volatile);\r
+      if (ConstAliasVal == NULL) {\r
+        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"alias", Param1);\r
+        ShellStatus = SHELL_INVALID_PARAMETER;\r
+      } else {\r
+        if (ShellCommandIsOnAliasList(Param1)) {\r
+          Volatile = FALSE;\r
+        }\r
+        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_ALIAS_OUTPUT), gShellLevel3HiiHandle, !Volatile?L' ':L'*', Param1, ConstAliasVal);\r
+      }      \r
     } else {\r
       ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"alias");  \r
       ShellStatus = SHELL_INVALID_PARAMETER;\r