summaryrefslogtreecommitdiffstats
path: root/ShellPkg/Application
Commit message (Collapse)AuthorAgeFilesLines
* ShellPkg: Update the comments of ReadKeyStroke and ReadKeyStrokeExQingyu2024-04-031-1/+3
| | | | | | | | | | | | | Refer to Uefi spec 2.10 section 12.3.3, Add a new retval EFI_UNSUPPORTED to EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.ReadKeyStrokeEx and EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke(). Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Zhichao Gao <zhichao.gao@intel.com> Cc: Chao Li <lichao@loongson.cn> Signed-off-by: Qingyu <qingyu.shang@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: Increase PcdShellPrintBufferSize from UINT16 to UINT32Giri Mudusuru2023-10-171-2/+3
| | | | | | | | | | Increase max buffer size to support more than 64K. Signed-off-by: Giri Mudusuru <girim@apple.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Cc: Andrew Fish <afish@apple.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: Fix conditionally uninitialized variablesMichael Kubacki2023-04-032-29/+32
| | | | | | | | | | | | | | | Fixes CodeQL alerts for CWE-457: https://cwe.mitre.org/data/definitions/457.html Cc: Erich McMillan <emcmillan@microsoft.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Michael Kubacki <mikuback@linux.microsoft.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Co-authored-by: Erich McMillan <emcmillan@microsoft.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Oliver Smith-Denny <osd@smith-denny.com>
* ShellPkg: Export default shell delay as PCDTomas Pilar2023-01-202-1/+2
| | | | | | | | | | | | | | | | | | | | | Create PcdShellDefaultDelay to configure the default delay the shell provides for the user at the start time if the user wishes to cancel the execution of a potential startup script. The shell application already allows the user to override the delay default value by specifying the -delay cmdline argument. This however cannot be used when loading the shell application using direct boot or when integrating the shell into the platform firmware build. Thus, a PCD can be easily configured by the developer either at build time, or even at runtime. Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Tomas Pilar <tomas@quicinc.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
* ShellPkg/Shell: Do not set end device path if already endMichael D Kinney2022-12-131-1/+7
| | | | | | | | | | | | | | | | | Update Shell Protocol EfiShellGetMapFromDevicePath() to not set the end if the device path if it is already an end of entire device path. This removes a write operation that can cause failures if the Device Path Protocol is mapped to read-only memory. In general Device Path Protocols should not be modified unless the API explicitly states that the device path is modified. Cc: Ard Biesheuvel <ardb@kernel.org> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: Apply uncrustify changesMichael Kubacki2021-12-0721-4599/+5193
| | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the ShellPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
* ShellPkg/ShellProtocol: sort files by FullName in RemoveDupInFileList()Laszlo Ersek2021-01-191-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current implementation of EfiShellRemoveDupInFileList(): - has quadratic time complexity, as a disadvantage, and - needs no dynamic memory, as an advantage. Because the UEFI Shell Spec requires EFI_SHELL_PROTOCOL.RemoveDupInFileList() to succeed at all times, keep the current method as a fallback (it cannot fail due to needing no dynamic memory). However, as a higher priority option, call the new ShellSortFileList() function at first, separating out and releasing duplicates. (ShellSortFileList() can fail due to EFI_OUT_OF_RESOURCES.) Beyond improving the runtime of EfiShellRemoveDupInFileList(), this change has the extremely desirable effect that the ShellOpenFileMetaArg() function in the ShellPkg/Library/UefiShellLib instance will produce file lists that are sorted by FullName. Consequently, when used with wildcards, the ATTRIB, CP, FOR, LOAD, LOADPCIROM, LS, MV, RM, TOUCH, TYPE commands will process files in FullName order. (LS in recursive mode uses wildcards internally.) Before: > FS2:\> dir -r -sfo apps > [...] > FileInfo,"FS2:\apps\" > FileInfo,"FS2:\apps\X64" > FileInfo,"FS2:\apps\AARCH64" > FileInfo,"FS2:\" > FileInfo,"FS2:\apps\IA32" > FileInfo,"FS2:\apps\X64\DumpDynPcd.efi" > FileInfo,"FS2:\apps\X64\SmiHandlerProfileInfo.efi" > FileInfo,"FS2:\apps\X64\" > FileInfo,"FS2:\apps\X64\VariableInfo.efi" > FileInfo,"FS2:\apps\X64\MemoryProfileInfo.efi" > FileInfo,"FS2:\apps\X64\AcpiViewApp.efi" > FileInfo,"FS2:\apps\X64\Cpuid.efi" > FileInfo,"FS2:\apps\" > FileInfo,"FS2:\apps\AARCH64\DumpDynPcd.efi" > FileInfo,"FS2:\apps\AARCH64\" > FileInfo,"FS2:\apps\AARCH64\VariableInfo.efi" > FileInfo,"FS2:\apps\AARCH64\MemoryProfileInfo.efi" > FileInfo,"FS2:\apps\AARCH64\AcpiViewApp.efi" > FileInfo,"FS2:\apps\" > FileInfo,"FS2:\apps\IA32\DumpDynPcd.efi" > FileInfo,"FS2:\apps\IA32\SmiHandlerProfileInfo.efi" > FileInfo,"FS2:\apps\IA32\" > FileInfo,"FS2:\apps\IA32\VariableInfo.efi" > FileInfo,"FS2:\apps\IA32\MemoryProfileInfo.efi" > FileInfo,"FS2:\apps\IA32\AcpiViewApp.efi" > FileInfo,"FS2:\apps\IA32\Cpuid.efi" > FileInfo,"FS2:\apps\" After: > FS2:\> dir -r -sfo apps > [...] > FileInfo,"FS2:\" > FileInfo,"FS2:\apps\" > FileInfo,"FS2:\apps\AARCH64" > FileInfo,"FS2:\apps\IA32" > FileInfo,"FS2:\apps\X64" > FileInfo,"FS2:\apps\" > FileInfo,"FS2:\apps\AARCH64\" > FileInfo,"FS2:\apps\AARCH64\AcpiViewApp.efi" > FileInfo,"FS2:\apps\AARCH64\DumpDynPcd.efi" > FileInfo,"FS2:\apps\AARCH64\MemoryProfileInfo.efi" > FileInfo,"FS2:\apps\AARCH64\VariableInfo.efi" > FileInfo,"FS2:\apps\" > FileInfo,"FS2:\apps\IA32\" > FileInfo,"FS2:\apps\IA32\AcpiViewApp.efi" > FileInfo,"FS2:\apps\IA32\Cpuid.efi" > FileInfo,"FS2:\apps\IA32\DumpDynPcd.efi" > FileInfo,"FS2:\apps\IA32\MemoryProfileInfo.efi" > FileInfo,"FS2:\apps\IA32\SmiHandlerProfileInfo.efi" > FileInfo,"FS2:\apps\IA32\VariableInfo.efi" > FileInfo,"FS2:\apps\" > FileInfo,"FS2:\apps\X64\" > FileInfo,"FS2:\apps\X64\AcpiViewApp.efi" > FileInfo,"FS2:\apps\X64\Cpuid.efi" > FileInfo,"FS2:\apps\X64\DumpDynPcd.efi" > FileInfo,"FS2:\apps\X64\MemoryProfileInfo.efi" > FileInfo,"FS2:\apps\X64\SmiHandlerProfileInfo.efi" > FileInfo,"FS2:\apps\X64\VariableInfo.efi" Regarding LS in non-SFO mode, the stability of ShellSortFileList() shows. The ShellSortFileList() call added to LS in the previous patch re-sorts the output of ShellOpenFileMetaArg(); and so this patch improves the ordering between identical FileNames: Before: > FS2:\> dir -r apps > Directory of: FS2:\apps\ > 01/01/1970 01:00 <DIR> r 0 . > 01/01/1970 01:00 <DIR> r 0 .. > 12/22/2020 17:53 <DIR> 4,096 AARCH64 > 12/22/2020 17:53 <DIR> 4,096 IA32 > 12/22/2020 17:53 <DIR> 4,096 X64 > 0 File(s) 0 bytes > 5 Dir(s) > Directory of: FS2:\apps\X64\ > 01/01/1970 01:00 <DIR> r 0 . > 01/01/1970 01:00 <DIR> r 0 .. > 12/22/2020 17:53 126,656 AcpiViewApp.efi > 12/22/2020 17:53 38,784 Cpuid.efi > 12/22/2020 17:52 18,752 DumpDynPcd.efi > 12/22/2020 17:52 26,304 MemoryProfileInfo.efi > 12/22/2020 17:52 34,240 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 11,456 VariableInfo.efi > 6 File(s) 256,192 bytes > 2 Dir(s) > Directory of: FS2:\apps\AARCH64\ > 01/01/1970 01:00 <DIR> r 0 . > 01/01/1970 01:00 <DIR> r 0 .. > 12/22/2020 17:53 139,264 AcpiViewApp.efi > 12/22/2020 17:52 32,768 DumpDynPcd.efi > 12/22/2020 17:52 40,960 MemoryProfileInfo.efi > 12/22/2020 17:52 20,480 VariableInfo.efi > 4 File(s) 233,472 bytes > 2 Dir(s) > Directory of: FS2:\apps\IA32\ > 01/01/1970 01:00 <DIR> r 0 . > 01/01/1970 01:00 <DIR> r 0 .. > 12/22/2020 17:53 105,536 AcpiViewApp.efi > 12/22/2020 17:53 36,096 Cpuid.efi > 12/22/2020 17:52 17,344 DumpDynPcd.efi > 12/22/2020 17:52 24,192 MemoryProfileInfo.efi > 12/22/2020 17:52 30,720 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 10,880 VariableInfo.efi > 6 File(s) 224,768 bytes > 2 Dir(s) > > FS2:\> dir apps\*\*.efi > Directory of: FS2:\apps\*\ > 12/22/2020 17:53 126,656 AcpiViewApp.efi > 12/22/2020 17:53 139,264 AcpiViewApp.efi > 12/22/2020 17:53 105,536 AcpiViewApp.efi > 12/22/2020 17:53 38,784 Cpuid.efi > 12/22/2020 17:53 36,096 Cpuid.efi > 12/22/2020 17:52 18,752 DumpDynPcd.efi > 12/22/2020 17:52 32,768 DumpDynPcd.efi > 12/22/2020 17:52 17,344 DumpDynPcd.efi > 12/22/2020 17:52 26,304 MemoryProfileInfo.efi > 12/22/2020 17:52 40,960 MemoryProfileInfo.efi > 12/22/2020 17:52 24,192 MemoryProfileInfo.efi > 12/22/2020 17:52 34,240 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 30,720 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 11,456 VariableInfo.efi > 12/22/2020 17:52 20,480 VariableInfo.efi > 12/22/2020 17:52 10,880 VariableInfo.efi > 16 File(s) 714,432 bytes > 0 Dir(s) After: > FS2:\> dir -r apps > Directory of: FS2:\apps\ > 01/01/1970 01:00 <DIR> r 0 . > 01/01/1970 01:00 <DIR> r 0 .. > 12/22/2020 17:53 <DIR> 4,096 AARCH64 > 12/22/2020 17:53 <DIR> 4,096 IA32 > 12/22/2020 17:53 <DIR> 4,096 X64 > 0 File(s) 0 bytes > 5 Dir(s) > Directory of: FS2:\apps\AARCH64\ > 01/01/1970 01:00 <DIR> r 0 . > 01/01/1970 01:00 <DIR> r 0 .. > 12/22/2020 17:53 139,264 AcpiViewApp.efi > 12/22/2020 17:52 32,768 DumpDynPcd.efi > 12/22/2020 17:52 40,960 MemoryProfileInfo.efi > 12/22/2020 17:52 20,480 VariableInfo.efi > 4 File(s) 233,472 bytes > 2 Dir(s) > Directory of: FS2:\apps\IA32\ > 01/01/1970 01:00 <DIR> r 0 . > 01/01/1970 01:00 <DIR> r 0 .. > 12/22/2020 17:53 105,536 AcpiViewApp.efi > 12/22/2020 17:53 36,096 Cpuid.efi > 12/22/2020 17:52 17,344 DumpDynPcd.efi > 12/22/2020 17:52 24,192 MemoryProfileInfo.efi > 12/22/2020 17:52 30,720 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 10,880 VariableInfo.efi > 6 File(s) 224,768 bytes > 2 Dir(s) > Directory of: FS2:\apps\X64\ > 01/01/1970 01:00 <DIR> r 0 . > 01/01/1970 01:00 <DIR> r 0 .. > 12/22/2020 17:53 126,656 AcpiViewApp.efi > 12/22/2020 17:53 38,784 Cpuid.efi > 12/22/2020 17:52 18,752 DumpDynPcd.efi > 12/22/2020 17:52 26,304 MemoryProfileInfo.efi > 12/22/2020 17:52 34,240 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 11,456 VariableInfo.efi > 6 File(s) 256,192 bytes > 2 Dir(s) > > FS2:\> dir apps\*\*.efi > Directory of: FS2:\apps\*\ > 12/22/2020 17:53 139,264 AcpiViewApp.efi > 12/22/2020 17:53 105,536 AcpiViewApp.efi > 12/22/2020 17:53 126,656 AcpiViewApp.efi > 12/22/2020 17:53 36,096 Cpuid.efi > 12/22/2020 17:53 38,784 Cpuid.efi > 12/22/2020 17:52 32,768 DumpDynPcd.efi > 12/22/2020 17:52 17,344 DumpDynPcd.efi > 12/22/2020 17:52 18,752 DumpDynPcd.efi > 12/22/2020 17:52 40,960 MemoryProfileInfo.efi > 12/22/2020 17:52 24,192 MemoryProfileInfo.efi > 12/22/2020 17:52 26,304 MemoryProfileInfo.efi > 12/22/2020 17:52 30,720 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 34,240 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 20,480 VariableInfo.efi > 12/22/2020 17:52 10,880 VariableInfo.efi > 12/22/2020 17:52 11,456 VariableInfo.efi > 16 File(s) 714,432 bytes > 0 Dir(s) Cc: Philippe Mathieu-Daudé <philmd@redhat.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3151 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Message-Id: <20210113085453.10168-9-lersek@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
* ShellPkg/AcpiView: Add application wrapperTomas Pilar2020-06-303-0/+196
| | | | | | | | | | | | | | | | | | | Simple application wrapper that invokes the shell command wrapper for 'acpiview'. This allows the AcpiView functionality to be used on platforms with older specifications of the UEFI shell or where the 'acpiview' command is not built in due to platform build configuration. Furthermore, this app can be integrated into more comprehensive testing frameworks as a single component of a more thorough specification compliance validation strategy. Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
* ShellPkg: Document UpdateArgcArgv returns EFI_INVALID_PARAMETERPhilippe Mathieu-Daud?2020-02-112-0/+3
| | | | | | | | ShellParametersProtocol::UpdateArgcArgv() can return a EFI_INVALID_PARAMETER value. Document it. Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Philippe Mathieu-Daude <philmd@redhat.com>
* ShellPkg: Document ParseCommandLineToArgs returns EFI_INVALID_PARAMETERPhilippe Mathieu-Daud?2020-02-112-0/+2
| | | | | | | | ShellParametersProtocol::ParseCommandLineToArgs() can return a EFI_INVALID_PARAMETER value. Document it. Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Philippe Mathieu-Daude <philmd@redhat.com>
* ShellPkg/Application: Fix various typosAntoine Coeur2020-02-1016-106/+106
| | | | | | | | | | | | Fix various typos in comments and documentation. Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Antoine Coeur <coeur@gmx.fr> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Philippe Mathieu-Daude <philmd@redhat.com> Message-Id: <20200207010831.9046-68-philmd@redhat.com>
* ShellPkg/ShellProtocol: Return error code while fail parsing cmd-lineZhichao Gao2019-12-191-1/+4
| | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2395 Errors happened in the arguments parsing is not a critical error. And it would miss the error status code in the release version of shell. So replace the ASSERT with returning error status code while fail parsing command-line in UpdateArgcArgv. Cc: Ray Ni <ray.ni@intel.com> Cc: Linson Augustine <linson.augustine@intel.com> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/Shell/FileHandleWrappers.c: Add check for MemFile->BufferShenglei Zhang2019-11-061-0/+7
| | | | | | | | | | Add check for MemFile->Buffer. Return EFI_OUT_OF_RESOURCES if MemFile->Buffer is NULL. Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: Unload image on EFI_SECURITY_VIOLATIONDandan Bi2019-09-251-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | For the LoadImage() boot service, with EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now. This follows UEFI Spec. But if the caller of LoadImage() doesn't have the option to defer the execution of an image, we can not treat EFI_SECURITY_VIOLATION like any other LoadImage() error, we should unload image for the EFI_SECURITY_VIOLATION to avoid resource leak. This patch is to do error handling for EFI_SECURITY_VIOLATION explicitly for the callers in ShellPkg which don't have the policy to defer the execution of the image. Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Philippe Mathieu-Daude <philmd@redhat.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1992 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
* ShellPkg: Replace BSD License with BSD+Patent LicenseMichael D Kinney2019-04-0926-178/+26
| | | | | | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=1373 Replace BSD 2-Clause License with BSD+Patent License. This change is based on the following emails: https://lists.01.org/pipermail/edk2-devel/2019-February/036260.html https://lists.01.org/pipermail/edk2-devel/2018-October/030385.html RFCs with detailed process for the license change: V3: https://lists.01.org/pipermail/edk2-devel/2019-March/038116.html V2: https://lists.01.org/pipermail/edk2-devel/2019-March/037669.html V1: https://lists.01.org/pipermail/edk2-devel/2019-March/037500.html Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: add array index check for shell delay optionZhichao Gao2019-02-221-2/+6
| | | | | | | | | | | | | | | | BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1528 Shell delay option without parameters do not check the index of shell parameter argv. Add index check to avoid invalid pointer references. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* ShellPkg/Shell: Use BaseLib api CharToUpperShenglei Zhang2019-01-311-23/+2
| | | | | | | | | | | | | | | Substitute InternalShellCharToUpper with a public function CharToUpper which has the same function. Remove the implement of InternalShellCharToUpper. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jaben Carsey <jaben.carsey@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg-ShellApp: Provide fully-qualified path to shell scriptsJim.Dailey@dell.com2018-11-051-3/+23
| | | | | | | | | | | | | | | Provide fully-qualified path to shell scripts Section 3.6.2 of version 2.2 of the shell specification requires that the first positional argument (i.e. arg 0) of a shell script resolves to "the full path name of the script itself." Ensure that the startup script and any scripts launched by the shell meet this requirement. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jim Dailey <jim_dailey@dell.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
* ShellPkg: Create a homefilesystem environment variableJim.Dailey@dell.com2018-10-031-0/+2
| | | | | | | | | | | | | | | | | | Create a homefilesystem environment variable whose value is the file system on which the executing shell is located. For example: "FS14:". This eliminates the need for people to have to try and find the "boot" file system in their startup script. After this change they can simply execute %homefilesystem% to set the cwd to the root of the file system where the shell is located. A future enhancement could be to add "homefilesystem" to the list of predefined, read-only variables listed in the EfiShellSetEnv function of file ShellProtocol.c Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jim Dailey <jim_dailey@dell.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg/Shell: Remove unused PCDsshenglei2018-09-301-2/+0
| | | | | | | | | | | | | | The PCDs below are unused, so they have been removed from inf. gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize gEfiShellPkgTokenSpaceGuid.PcdShellMapNameLength Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: shenglei <shenglei.zhang@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg Shell: Remove an unused global variableshenglei2018-09-071-3/+0
| | | | | | | | | | | | | The unused global variable InvalidChars is removed. It is only used in the function IsValidCommandName which was removed previously. https://bugzilla.tianocore.org/show_bug.cgi?id=1066 Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: shenglei <shenglei.zhang@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
* ShellPkg Shell: Remove redundant functionsshenglei2018-09-064-146/+1
| | | | | | | | | | | | | The redundant functions which are never called have been removed. They are InternalShellProtocolDebugPrintMessage, UpdateFileName,RemoveFileTag and IsValidCommandName. https://bugzilla.tianocore.org/show_bug.cgi?id=1066 Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: shenglei <shenglei.zhang@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg/redirection: Insert \xFEFF for ENV variable redirectionRuiyu Ni2018-08-161-7/+27
| | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1080 Per Shell spec 2.2 chapter 3.4.4.2, Unicode file tag should be inserted in the output from the input redirected variable, to ensure it looks like a UCS-2 encode file. The patch fixes this issue. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg/redirection: Insert \xFEFF after converting ASCII to UnicodeRuiyu Ni2018-08-161-15/+31
| | | | | | | | | | | | | When "<a" is used to redirect ASCII file to an application, Shell core reads the ASCII file and converts the ASCII to Unicode as the input source of the application. But per Shell spec, the input source should have \xFEFF to indicate it's a Unicode stream. The patch adds the missing \xFEFF. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg/set: Fix EfiShellSetEnv to use case sensitive compareRuiyu Ni2018-08-161-30/+9
| | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=777 Per Shell spec, the environment variable has a case-sensitive name. But today's implementation of EfiShellSetEnv() compares the environment variable name case insensitively, which causes variable like "CWD" cannot be set due to "cwd" is pre-defined variable. The patch fixes this issue. The EfiShellGetEnv() doesn't have such issue because it will call into ShellFindEnvVarInList() which uses StrCmp(). Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Jim Dailey <jim_dailey@dell.com>
* ShellPkg: Removing ipf which is no longer supported from edk2.chenc22018-06-294-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Removing rules for Ipf sources file: * Remove the source file which path with "ipf" and also listed in [Sources.IPF] section of INF file. * Remove the source file which listed in [Components.IPF] section of DSC file and not listed in any other [Components] section. * Remove the embedded Ipf code for MDE_CPU_IPF. Removing rules for Inf file: * Remove IPF from VALID_ARCHITECTURES comments. * Remove DXE_SAL_DRIVER from LIBRARY_CLASS in [Defines] section. * Remove the INF which only listed in [Components.IPF] section in DSC. * Remove statements from [BuildOptions] that provide IPF specific flags. * Remove any IPF sepcific sections. Removing rules for Dec file: * Remove [Includes.IPF] section from Dec. Removing rules for Dsc file: * Remove IPF from SUPPORTED_ARCHITECTURES in [Defines] section of DSC. * Remove any IPF specific sections. * Remove statements from [BuildOptions] that provide IPF specific flags. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Chen A Chen <chen.a.chen@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: Clean up source filesLiming Gao2018-06-2814-220/+220
| | | | | | | | | | 1. Do not use tab characters 2. No trailing white space in one line 3. All files must end with CRLF Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
* ShellPkg/ConsoleLogger: Fix a typo in UpdateDisplayFromHistory()Hao Wu2018-03-041-2/+2
| | | | | | | | | | | | | | | | | | | | Within function UpdateDisplayFromHistory(): When getting a character with different attribute with the current one, the statement to compare the character with a 'NULL' char should be: *StringSegmentEnd != CHAR_NULL rather than: StringSegmentEnd != CHAR_NULL This commit resolves this typo. Cc: Jaben Carsey <jaben.carsey@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
* ShellPkg/help: Fix "-?" may not show manual sometimesRuiyu Ni2018-02-132-254/+73
| | | | | | | | | | | | | | | | | | Shell core was enhanced to find the manual string in PE resource section. But the finding algorithm is too strict: If the manual is written beginning with: .TH command 0 "descripton of command" but user types "COMMAND.efi -?". The finding algorithm uses case-sensitive compare between "command" and "COMMAND" resulting in the manual cannot be found. The patch fixes this issue by using existing ManFileFindTitleSection and ManFileFindSections which compare command case-insensitive. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: Fix the bug that handling Ctrl-C improperlyRuiyu Ni2017-11-291-6/+6
| | | | | | | | | | | | | Current implementation resets the CTRL-C event early when printing the shell prompt, when user types "<CTRL-C>ls<ENTER>", "ls" command is terminated immediately when starts. It's not an expected behavior from users' perspective. Correct way is to reset the CTRL-C event just before running the command, which is a bit later than current point. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg/Shell: Check the OpenVolume result in OpenRootByHandle()Hao Wu2017-11-151-2/+7
| | | | | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=779 For the API EfiShellOpenRootByHandle(): The return status of the call to SimpleFileSystem->OpenVolume should be checked. It is possible that there is a media change in the device (like CD/DVD ROM). In such case, the volume root opened and/or the device path opened previously (also within EfiShellOpenRootByHandle) may be invalid. This commit adds a check for the result of OpenVolume before subsequently calling functions like EfiShellGetMapFromDevicePath() & ConvertEfiFileProtocolToShellHandle(). Cc: Jaben Carsey <jaben.carsey@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
* ShellPkg: Fix MSFT C4255 warningSong, BinX2017-11-142-0/+3
| | | | | | | | | | | | | | | | | | | V2: Fix MSFT C4255 warning V1: Enable MSFT C4255 warning. From MSDN: Compiler Warning (level 4) C4255 function' : no function prototype given: converting '()' to '(void)' The compiler did not find an explicit list of arguments to a function. This warning is for the C compiler only. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bell Song <binx.song@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: Fix misuses of AllocateCopyPoolJian J Wang2017-11-081-1/+3
| | | | | | | | | | | | | | | | | AllocateCopyPool(AllocationSize, *Buffer) will copy "AllocationSize" bytes of memory from old "Buffer" to new allocated one. If "AllocationSize" is bigger than size of "Buffer", heap memory overflow occurs during copy. One solution is to allocate pool first then copy the necessary bytes to new memory. Another is using ReallocatePool instead if old buffer will be freed on spot. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Bi Dandan <dandan.bi@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
* ShellPkg/Shell: Avoid reading content beyond string boundaryHao Wu2017-09-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=690 Within function EfiShellGetDevicePathFromFilePath(), when the input parameter 'Path' string is like: "FS0:" It is possible for the below statement: "if (*(Path+StrLen(MapName)+1) == CHAR_NULL) {" to read the content 1 byte beyond the string boundary (both 'Path' and 'MapName' will be FS0: in this case). This commit adds additional checks to avoid this. Cc: Steven Shi <steven.shi@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
* ShellPkg: Update CWD and current mapping when commands returnHuajing Li2017-08-301-1/+17
| | | | | | | | | | | | | Some commands may cause current directory or even current mapping become invalid. For example, "MAP" after unplugging the USB thumb key may cause current mapping "FS0:" disappear. This patch updates the CWD and current mapping when commands return. It also causes the command prompt change to default "Shell>". Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Huajing Li <huajing.li@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: Rename gShellCurDir to gShellCurMappingHuajing Li2017-08-301-4/+4
| | | | | | | Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Huajing Li <huajing.li@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: Avoid buffer out-of-bound accessRuiyu Ni2017-07-281-1/+1
| | | | | | | | | | | PathSize is the number of bytes in PathForReturn buffer so PathForReturn[PathSize - 1] incorrectly accesses the last character in the buffer, PathForReturn[PathSize / sizeof (CHAR16) - 1] should be used. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Steven Shi <steven.shi@intel.com>
* ShellPkg/alias: Fix bug to support upper-case aliasRuiyu Ni2017-06-051-25/+25
| | | | | | | | | | | | | | | alias in UEFI Shell is case insensitive. Old code saves the alias to variable storage without converting the alias to lower-case, which results upper case alias setting doesn't work. The patch converts the alias to lower case before saving to variable storage. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Tapan Shah <tapandshah@hpe.com>
* ShellPkg/Shell: eliminate double-free in RunSplitCommand()Laszlo Ersek2017-04-261-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit bd3fc8133b2b ("ShellPkg/App: Fix memory leak and save resources.", 2016-05-20) added a FreePool() call for Split->SplitStdIn, near end of the RunSplitCommand(), right after the same shell file was closed with CloseFile(). The argument was: > 1) RunSplitCommand() allocates the initial SplitStdOut via > CreateFileInterfaceMem(). Free SplitStdIn after the swap to fix > the memory leak. There is no memory leak actually, and the FreePool() call in question constitutes a double-free: (a) This is how the handle is established: ConvertEfiFileProtocolToShellHandle ( CreateFileInterfaceMem (Unicode), NULL ); CreateFileInterfaceMem() allocates an EFI_FILE_PROTOCOL_MEM object and populates it fully. ConvertEfiFileProtocolToShellHandle() allocates some administrative structures and links the EFI_FILE_PROTOCOL_MEM object into "mFileHandleList". (b) EFI_SHELL_PROTOCOL.CloseFile() is required to close the SHELL_FILE_HANDLE and to release all associated data. Accordingly, near the end of RunSplitCommand(), we have: EfiShellClose() ShellFileHandleRemove() // // undoes the effects of ConvertEfiFileProtocolToShellHandle() // ConvertShellHandleToEfiFileProtocol() // // note that this does not adjust the pointer value; it's a pure // type cast // FileHandleClose() FileInterfaceMemClose() // // tears down EFI_FILE_PROTOCOL_MEM completely, undoing the // effects of CreateFileInterfaceMem () // The FreePool() call added by bd3fc8133b2b conflicts with SHELL_FREE_NON_NULL(This); in FileInterfaceMemClose(), so remove it. This error can be reproduced for example with: > Shell> map | more > 'more' is not recognized as an internal or external command, operable > program, or script file. which triggers: > ASSERT MdeModulePkg/Core/Dxe/Mem/Pool.c(624): CR has Bad Signature with the following stack dump: > #0 0x000000007f6dc094 in CpuDeadLoop () at > MdePkg/Library/BaseLib/CpuDeadLoop.c:37 > #1 0x000000007f6dd1b4 in DebugAssert (FileName=0x7f6ed9f0 > "MdeModulePkg/Core/Dxe/Mem/Pool.c", LineNumber=624, > Description=0x7f6ed9d8 "CR has Bad Signature") at > OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c:153 > #2 0x000000007f6d075d in CoreFreePoolI (Buffer=0x7e232c98, > PoolType=0x7f6bc1c4) at MdeModulePkg/Core/Dxe/Mem/Pool.c:624 > #3 0x000000007f6d060e in CoreInternalFreePool (Buffer=0x7e232c98, > PoolType=0x7f6bc1c4) at MdeModulePkg/Core/Dxe/Mem/Pool.c:529 > #4 0x000000007f6d0648 in CoreFreePool (Buffer=0x7e232c98) at > MdeModulePkg/Core/Dxe/Mem/Pool.c:552 > #5 0x000000007d49fbf8 in FreePool (Buffer=0x7e232c98) at > MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c:818 > #6 0x000000007d4875c3 in RunSplitCommand (CmdLine=0x7d898398, > StdIn=0x0, StdOut=0x0) at ShellPkg/Application/Shell/Shell.c:1813 > #7 0x000000007d487d59 in ProcessNewSplitCommandLine > (CmdLine=0x7d898398) at ShellPkg/Application/Shell/Shell.c:2121 > #8 0x000000007d488937 in RunShellCommand (CmdLine=0x7e233018, > CommandStatus=0x0) at ShellPkg/Application/Shell/Shell.c:2670 > #9 0x000000007d488b0b in RunCommand (CmdLine=0x7e233018) at > ShellPkg/Application/Shell/Shell.c:2732 > #10 0x000000007d4867c8 in DoShellPrompt () at > ShellPkg/Application/Shell/Shell.c:1349 > #11 0x000000007d48524d in UefiMain (ImageHandle=0x7e24c898, > SystemTable=0x7f5b6018) at ShellPkg/Application/Shell/Shell.c:631 Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Marvin Häuser <Marvin.Haeuser@outlook.com> Cc: Qiu Shumin <shumin.qiu@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Fixes: bd3fc8133b2b17ad2e0427d1bf6b44b08cf2f3b2 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Marvin Häuser <Marvin.Haeuser@outlook.com>
* ShellPkg/Shell: clean up bogus member types in SPLIT_LISTLaszlo Ersek2017-04-262-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "SPLIT_LIST.SplitStdOut" and "SPLIT_LIST.SplitStdIn" members currently have type (SHELL_FILE_HANDLE *). This is wrong; SHELL_FILE_HANDLE is already a pointer, there's no need to store a pointer to a pointer. The error is obvious if we check where and how these members are used: - In the RunSplitCommand() function, these members are used (populated) extensively; this function has to be updated in sync. ConvertEfiFileProtocolToShellHandle() already returns the temporary memory file created with CreateFileInterfaceMem() as SHELL_FILE_HANDLE, not as (SHELL_FILE_HANDLE *). - In particular, the ConvertShellHandleToEfiFileProtocol() calls need to be dropped as well in RunSplitCommand(), since EFI_SHELL_PROTOCOL.SetFilePosition() and EFI_SHELL_PROTOCOL.CloseFile() take SHELL_FILE_HANDLE parameters, not (EFI_FILE_PROTOCOL *). Given that ConvertShellHandleToEfiFileProtocol() only performs a type-cast (it does not adjust any pointer values), *and* SHELL_FILE_HANDLE -- taken by EFI_SHELL_PROTOCOL member functions -- is actually a typedef to (VOID *) -- see more on this later --, this conversion error hasn't been caught by compilers. - In the ProcessNewSplitCommandLine() function, RunSplitCommand() is called either initially (passing in NULL / NULL; no update needed), or recursively (passing in Split->SplitStdIn / Split->SplitStdOut; again no update is necessary beyond the RunSplitCommand() modification above). - In the UpdateStdInStdOutStdErr() and RestoreStdInStdOutStdErr() functions, said structure members are compared and assigned to "EFI_SHELL_PARAMETERS_PROTOCOL.StdIn" and "EFI_SHELL_PARAMETERS_PROTOCOL.StdOut", both of which have type SHELL_FILE_HANDLE, *not* (SHELL_FILE_HANDLE *). The compiler hasn't caught this error because of the fatally flawed type definition of SHELL_FILE_HANDLE, namely typedef VOID *SHELL_FILE_HANDLE; Pointer-to-void silently converts to and from most other pointer types; among them, pointer-to-pointer-to-void. That is also why no update is necessary for UpdateStdInStdOutStdErr() and RestoreStdInStdOutStdErr() in this fix. ( Generally speaking, using (VOID *) typedefs for opaque handles is a tragic mistake in all of the UEFI-related specifications; this practice defeats any type checking that compilers might help programmers with. The right way to define an opaque handle is as follows: // // Introduce the incomplete structure type, and the derived pointer // type, in both the specification and the public edk2 headers. Note // that the derived pointer type itself is a complete type, and it can // be used freely by client code. // typedef struct SHELL_FILE *SHELL_FILE_HANDLE; // // Complete the structure type in the edk2 internal C source files. // struct SHELL_FILE { // // list fields // }; This way the structure size and members remain hidden from client code, but the C compiler can nonetheless catch any invalid conversions between incompatible XXX_HANDLE types. ) Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Marvin Häuser <Marvin.Haeuser@outlook.com> Cc: Qiu Shumin <shumin.qiu@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: Fix Shell to not return without startup.nsh after timeoutRuiyu Ni2017-04-071-0/+5
| | | | | | | | | | | When user doesn't press key to exit the timeout waiting in Shell, and there is no startup.nsh, Shell exits with failure status. aaf51f08ee104447207bba571649556095befc93 introduced this bug. The patch fixes this issue. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Chen A Chen <chen.a.chen@intel.com>
* ShellPkg/Shell: Avoid potential null pointer deferenceRuiyu Ni2017-03-291-0/+6
| | | | | | Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* ShellPkg/Shell: Make comments align with the functionDandan Bi2017-03-281-2/+2
| | | | | | | | Cc: Chen A Chen <chen.a.chen@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
* ShellPkg: Add Shell invocation option '-exit'Chen A Chen2017-03-232-3/+3
| | | | | | | | | | According to Shell spec 2.2 '-exit' invocation option is used to specify that after running the command line when launched, the UEFI Shell must immediately exit. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chen A Chen <chen.a.chen@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: Fix shell not able to run startup.nshChen A Chen2017-03-231-58/+56
| | | | | | | Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chen A Chen <chen.a.chen@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: add GUID declaration for FILE_GUID of UEFI Shell app to packageArd Biesheuvel2017-03-221-1/+1
| | | | | | | | | | | | | In QuarkPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.c, there is a definition of mUefiShellFileGuid which is a constant reference to the FILE_GUID as defined in ShellPkg/Application/Shell/Shell.inf. To prevent the need for duplicating it to other modules, promote it to a proper global GUID, and add it to the ShellPkg.dec package declaration. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: Refine type cast for pointer subtractionHao Wu2017-03-061-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For pointer subtraction, the result is of type "ptrdiff_t". According to the C11 standard (Committee Draft - April 12, 2011): "When two pointers are subtracted, both shall point to elements of the same array object, or one past the last element of the array object; the result is the difference of the subscripts of the two array elements. The size of the result is implementation-defined, and its type (a signed integer type) is ptrdiff_t defined in the <stddef.h> header. If the result is not representable in an object of that type, the behavior is undefined." In our codes, there are cases that the pointer subtraction is not performed by pointers to elements of the same array object. This might lead to potential issues, since the behavior is undefined according to C11 standard. Also, since the size of type "ptrdiff_t" is implementation-defined. Some static code checkers may warn that the pointer subtraction might underflow first and then being cast to a bigger size. For example: UINT8 *Ptr1, *Ptr2; UINTN PtrDiff; ... PtrDiff = (UINTN) (Ptr1 - Ptr2); The commit will refine the pointer subtraction expressions by casting each pointer to UINTN first and then perform the subtraction: PtrDiff = (UINTN) Ptr1 - (UINTN) Ptr2; Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Acked-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg/Shell: Add double quotes to args with white spaceMichael Kinney2017-01-111-9/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=332 When the ShellLib ShellExecute() API or the Shell Protocol Execute() API are used to execute a command, the arguments are parsed to produce the Argc/Argv list in the Shell Parameters Protocol and double quotes are removed from arguments that are surrounded by double quotes. This is the required behavior of the Shell Parameters Protocol. The ProcessCommandLine() function in the shell implementation uses the Argc/Argv list from the Shell Parameters Protocol to assemble a new command line, but the double quotes that may have been originally present for an argument are not preserved. ProcessCommandLine() is updated to check if an argument added to the generated command line contains one or more white space characters, and if it does, double quotes are added around the argument. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Ruiyu Ni <Ruiyu.ni@intel.com>
* ShellPkg: Fix a bug ">>v" cannot append data to environment variableChen A Chen2017-01-061-1/+5
| | | | | | | | | | | | | When ">v" is used to redirect the command output to environment variable, the ending "\r\n\0" is removed before setting to environment variable but the length is not updated. It causes ">>v" fails to append data to the environment variable created by ">v". The patch fixes the above bug. Signed-off-by: Chen A Chen <chen.a.chen@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg/Application: Fix ">v" cannot update environment variableChen A Chen2016-12-093-44/+142
| | | | | | | | | | | | | | | | | When ">v" is used to redirect the command output to environment variable (e.g.: "echo xxx >v yyy"), we only called SetVariable() to update the variable storage but forgot to update the cached environment variables in gShellEnvVarList. When updating the variable storage, the existing code unnecessary saved the ending NULL character into variable storage. The patch fixes all the above issues. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chen A Chen <chen.a.chen@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Tapan Shah <tapandshah@hpe.com>