TestArgv.nsh is a very simple shell script to test how the interpreter parses the parameters. It uses Argv.efi to dump the parameters passed from the interpreter.
TestArgv.log is the desired output created by "TestArgv.nsh > TestArgv.log". Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <[email protected]> Cc: Jaben Carsey <[email protected]> --- ShellPkg/Application/Argv/Argv.c | 50 +++++++++++++++++++++++++++++++++ ShellPkg/Application/Argv/Argv.inf | 39 +++++++++++++++++++++++++ ShellPkg/Application/Argv/README.txt | 5 ++++ ShellPkg/Application/Argv/TestArgv.log | Bin 0 -> 2922 bytes ShellPkg/Application/Argv/TestArgv.nsh | 41 +++++++++++++++++++++++++++ 5 files changed, 135 insertions(+) create mode 100644 ShellPkg/Application/Argv/Argv.c create mode 100644 ShellPkg/Application/Argv/Argv.inf create mode 100644 ShellPkg/Application/Argv/README.txt create mode 100644 ShellPkg/Application/Argv/TestArgv.log create mode 100644 ShellPkg/Application/Argv/TestArgv.nsh diff --git a/ShellPkg/Application/Argv/Argv.c b/ShellPkg/Application/Argv/Argv.c new file mode 100644 index 0000000..4f853ec --- /dev/null +++ b/ShellPkg/Application/Argv/Argv.c @@ -0,0 +1,50 @@ +/** @file + This is a very simple shell application that prints out all parameters it receives. + + 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. + +**/ + +#include <Uefi.h> +#include <Library/UefiLib.h> +#include <Library/DebugLib.h> +#include <Library/ShellCEntryLib.h> + +/** + UEFI application entry point which has an interface similar to a + standard C main function. + + The ShellCEntryLib library instance wrappers the actual UEFI application + entry point and calls this ShellAppMain function. + + @param[in] Argc The number of items in Argv. + @param[in] Argv Array of pointers to strings. + + @retval 0 The application exited normally. + @retval Other An error occurred. + +**/ +INTN +EFIAPI +ShellAppMain ( + IN UINTN Argc, + IN CHAR16 **Argv + ) +{ + UINTN 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; +} diff --git a/ShellPkg/Application/Argv/Argv.inf b/ShellPkg/Application/Argv/Argv.inf new file mode 100644 index 0000000..ce27c1d --- /dev/null +++ b/ShellPkg/Application/Argv/Argv.inf @@ -0,0 +1,39 @@ +## @file +# A simple shell application to dump all parameters it receives. +# +# 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. +# +# +## + +[Defines] + INF_VERSION = 0x00010006 + BASE_NAME = Argv + FILE_GUID = 6C52A2D2-A6D1-48BC-A8A6-3EEDF9B253EF + MODULE_TYPE = UEFI_APPLICATION + VERSION_STRING = 1.0 + ENTRY_POINT = ShellCEntryLib + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +[Sources] + Argv.c + +[Packages] + MdePkg/MdePkg.dec + ShellPkg/ShellPkg.dec + +[LibraryClasses] + ShellCEntryLib + UefiLib \ No newline at end of file diff --git a/ShellPkg/Application/Argv/README.txt b/ShellPkg/Application/Argv/README.txt new file mode 100644 index 0000000..7fc63f8 --- /dev/null +++ b/ShellPkg/Application/Argv/README.txt @@ -0,0 +1,5 @@ +TestArgv.nsh is a very simple shell script to test how the interpreter parses +the parameters. It uses Argv.efi to dump the parameters passed from the +intepreter. + +TestArgv.log is the desired output created by "TestArgv.nsh > TestArgv.log". \ No newline at end of file diff --git a/ShellPkg/Application/Argv/TestArgv.log b/ShellPkg/Application/Argv/TestArgv.log new file mode 100644 index 0000000000000000000000000000000000000000..0fd5cf57820783ebeb0554b3308d68ce7541265c GIT binary patch literal 2922 zcmcJRZ)+1l5XPU^g5P1el9z>~$)$-<;V!xOMwC+YjcpI9sTRZrtKz3uf3smp;{Dk| z?>O#uZ)bL%XJ%)1_wS#TE;Q5&UFxNr*1FLb-P1ef`%TaFOoti|==?zbULW;cr3&N= z-my|mX-l2(%or;*(JAc-y-Z6`Y;3F?%_SoX&H0+<iq`EtX8Wstg7j9mdPVO}pIW$F zz}eVruwP&?^$ZH|ryhF<_Ke=da~si{!JuHYq)kE3y)1*#g8vzkz~@>=Ey(9^yC)uN zEEUW)&kD~W_akF$XY?i-Axr7aks4+Rw>hIzA~N^#AzzE-4moK-4)M?M`?G#|v;u49 ze~uON{1p3{?@h3sdDPtFkC86XT!B4AYs5EYma%tec5SnoN4COutlC2_csn1e$iX|O zYaWw_kq^Y-idt|=kkmy#XxiLuUWAeTxku5tgU;(`(CA4YSh3h_<#n-1qOozTLer|4 zEQak`X2<3>Bgb(qo0|PLSq%Lt`B;sZ(;1okM(^~Rr>zbKoB`eMpv@T>tB*u|<g8=& zAE=KVyV=wFlgyaZ<-*SEP&sz0bhE41aeRD+B%H0=b1Bq8V7R~U{jYO)a|knRcir$d z*V-mp<%fLMSo_TzDl8z?b6b1eYCVLT%`tb4?(a7-ygn*0hS^6g#4!82w^Wh$?-<)v T4VlqhT~$#J@6fm0U`^*A{nC1H literal 0 HcmV?d00001 diff --git a/ShellPkg/Application/Argv/TestArgv.nsh b/ShellPkg/Application/Argv/TestArgv.nsh new file mode 100644 index 0000000..3aa7a9e --- /dev/null +++ b/ShellPkg/Application/Argv/TestArgv.nsh @@ -0,0 +1,41 @@ +#/** @file +# This is a very simple shell script to test how the intepreter 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 ^" + +# +# '^' should escape all special characters (including space) +# +Argv ^# +Argv ^%Var_EFCF356F_228C_47C2_AD0C_3B5DAC9A8CFA% +Argv ^" +Argv ^ 1 + +# +# '#' should be processed before %% replacement, and inside '"' +# +Argv #%Var_EFCF356F_228C_47C2_AD0C_3B5DAC9A8CFA% +Argv "#" +Argv %Sharp_E8528E46_A008_4221_8DE0_D5AB42A9C580% + +# +# '%' should be processed before grouping parameters +# +Argv "1 2%Quote_E95DEE8B_E3AA_4155_9ED5_6916394104FC% + + +set -d Var_EFCF356F_228C_47C2_AD0C_3B5DAC9A8CFA +echo -off \ No newline at end of file -- 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

