Revision: 19391
          http://sourceforge.net/p/edk2/code/19391
Author:   vanjeff
Date:     2015-12-18 07:27:10 +0000 (Fri, 18 Dec 2015)
Log Message:
-----------
ShellPkg: Add a simple case to test shell parameter parsing logic

TestArgv.nsh is a very simple shell script to test how the interpreter parses
the parameters. It uses ShellCTestApp.efi to dump the parameters passed from the
interpreter.

TestArgv.log is the desired output created using "TestArgv.nsh > TestArgv.log".

(Sync patch r18558 from main trunk.)

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

Revision Links:
--------------
    http://sourceforge.net/p/edk2/code/18558

Modified Paths:
--------------
    branches/UDK2015/ShellPkg/Application/ShellCTestApp/ShellCTestApp.c

Added Paths:
-----------
    branches/UDK2015/ShellPkg/Application/ShellCTestApp/README.txt
    branches/UDK2015/ShellPkg/Application/ShellCTestApp/TestArgv.log
    branches/UDK2015/ShellPkg/Application/ShellCTestApp/TestArgv.nsh

Added: branches/UDK2015/ShellPkg/Application/ShellCTestApp/README.txt
===================================================================
--- branches/UDK2015/ShellPkg/Application/ShellCTestApp/README.txt              
                (rev 0)
+++ branches/UDK2015/ShellPkg/Application/ShellCTestApp/README.txt      
2015-12-18 07:27:10 UTC (rev 19391)
@@ -0,0 +1,5 @@
+TestArgv.nsh is a very simple shell script to test how the interpreter parses
+the parameters. It uses ShellCTestApp.efi to dump the parameters passed from 
the
+intepreter.
+
+TestArgv.log is the desired output created using "TestArgv.nsh > TestArgv.log".
\ No newline at end of file

Modified: branches/UDK2015/ShellPkg/Application/ShellCTestApp/ShellCTestApp.c
===================================================================
--- branches/UDK2015/ShellPkg/Application/ShellCTestApp/ShellCTestApp.c 
2015-12-18 07:26:39 UTC (rev 19390)
+++ branches/UDK2015/ShellPkg/Application/ShellCTestApp/ShellCTestApp.c 
2015-12-18 07:27:10 UTC (rev 19391)
@@ -2,7 +2,7 @@
   This is a test application that demonstrates how to use the C-style entry 
point
   for a shell application.
 
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -40,11 +40,12 @@
   )
 {
   UINTN  Index;
-
-  Print(L"ShellCTestApp.c:ShellAppMain called with %d parameters\n", Argc);
-  for (Index = 0; Index < Argc; Index++) {
-    Print(L"Argv[%d]: %s\n", Index, Argv[Index]);
+  if (Argc == 1) {
+    Print (L"Argv[1] = NULL\n");
   }
+  for (Index = 1; Index < Argc; Index++) {
+    Print(L"Argv[%d]: \"%s\"\n", Index, Argv[Index]);
+  }
 
   return 0;
 }

Added: branches/UDK2015/ShellPkg/Application/ShellCTestApp/TestArgv.log
===================================================================
--- branches/UDK2015/ShellPkg/Application/ShellCTestApp/TestArgv.log            
                (rev 0)
+++ branches/UDK2015/ShellPkg/Application/ShellCTestApp/TestArgv.log    
2015-12-18 07:27:10 UTC (rev 19391)
@@ -0,0 +1,89 @@
+\xFF\xFEF++++++++++++++++++++++++++++++++++++++++++++\ No newline at end of 
file

Added: branches/UDK2015/ShellPkg/Application/ShellCTestApp/TestArgv.nsh
===================================================================
--- branches/UDK2015/ShellPkg/Application/ShellCTestApp/TestArgv.nsh            
                (rev 0)
+++ branches/UDK2015/ShellPkg/Application/ShellCTestApp/TestArgv.nsh    
2015-12-18 07:27:10 UTC (rev 19391)
@@ -0,0 +1,64 @@
+#/** @file
+#  This is a very simple shell script to test how the interpreter parses the 
parameters.
+#
+#  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+#**/
+echo -on
+set Var_EFCF356F_228C_47C2_AD0C_3B5DAC9A8CFA      ValueOfGuid
+set Sharp_E8528E46_A008_4221_8DE0_D5AB42A9C580    ^#
+set Quote_E95DEE8B_E3AA_4155_9ED5_6916394104FC    ^"
+set Var_ShellCTestApp_EE6E8BC6_71A6_44A5_BED3_D8F901105CDE 
ShellCTestApp_EE6E8BC6_71A6_44A5_BED3_D8F901105CDE
+alias ShellCTestApp_EE6E8BC6_71A6_44A5_BED3_D8F901105CDE   ShellCTestApp
+
+#
+# '^' should escape all special characters (including space)
+#     but has no impact to non-special characters
+#
+ShellCTestApp ^^
+ShellCTestApp ^#
+ShellCTestApp ^%Var_EFCF356F_228C_47C2_AD0C_3B5DAC9A8CFA%
+ShellCTestApp ^"
+ShellCTestApp ^ 1
+ShellCTestApp ^ 
+ShellCTestApp ^1
+ShellCTestApp ^^^"
+ShellCTestApp ^^^
+
+#
+# '#' should be processed before %% replacement, and inside '"'
+#
+ShellCTestApp #%Var_EFCF356F_228C_47C2_AD0C_3B5DAC9A8CFA%
+#ShellCTestApp "#"
+ShellCTestApp %Sharp_E8528E46_A008_4221_8DE0_D5AB42A9C580%
+
+#
+# '%' should be processed before grouping parameters
+#
+ShellCTestApp "%Var_EFCF356F_228C_47C2_AD0C_3B5DAC9A8CFA% 
2%Quote_E95DEE8B_E3AA_4155_9ED5_6916394104FC%
+
+#
+# alias should be processed after %% replacement
+#
+%Var_ShellCTestApp_EE6E8BC6_71A6_44A5_BED3_D8F901105CDE%
+
+#
+# '"' should be stripped, space inside '"' should be kept, 
+#
+ShellCTestApp "p   1"
+ShellCTestApp "p"1
+ShellCTestApp "p   1"e"x"""
+
+set -d Var_EFCF356F_228C_47C2_AD0C_3B5DAC9A8CFA
+set -d Sharp_E8528E46_A008_4221_8DE0_D5AB42A9C580
+set -d Quote_E95DEE8B_E3AA_4155_9ED5_6916394104FC
+set -d Var_ShellCTestApp_EE6E8BC6_71A6_44A5_BED3_D8F901105CDE
+alias -d ShellCTestApp_EE6E8BC6_71A6_44A5_BED3_D8F901105CDE
+echo -off
\ No newline at end of file


------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to