summaryrefslogtreecommitdiffstats
path: root/ShellPkg/Library/UefiShellLib/UefiShellLib.c
Commit message (Collapse)AuthorAgeFilesLines
* ShellPkg: Fix typosPage Chen2023-12-081-20/+20
| | | | | | | | | | | | | | | | | | | | begining->beginning dirve->drive duplicat->duplicate fuly->fully Funciton->Function Functino->Function optioanl->optional poitners->pointers rountine->routine sucessful->successful sucessfully->successfully Signed-off-by: Page Chen <paiching_chen@apple.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Cc: Andrew Fish <afish@apple.com> Message-Id: <829d2bed2a848229d719d7ae7b64ef1a47782720.1699557986.git.paiching_chen@apple.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: Increase PcdShellPrintBufferSize from UINT16 to UINT32Giri Mudusuru2023-10-171-9/+10
| | | | | | | | | | 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: Apply uncrustify changesMichael Kubacki2021-12-071-1010/+1209
| | | | | | | | | | | | 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: Fix spelling mistake for occurredMichael D Kinney2020-08-191-3/+3
| | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2361 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: Guomin Jiang <guomin.jiang@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/UefiShellLib: clarify workaround for unfixable EdkShell bugLaszlo Ersek2019-10-091-2/+20
| | | | | | | | | | | | | | | | | | | The EDK 1 Shell (available at <https://github.com/tianocore/edk-Shell>) has a bug in its EFI_SHELL_ENVIRONMENT2.Execute() implementation that edk2's UefiShellLib has no choice but to work around. Improve the explanation in the code. Also, document the implicit EFI_HANDLE -> (EFI_HANDLE*) conversion, which happens implicitly after dereferencing ParentHandle, with an explicit cast. In practice, this patch is a no-op. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: stop using EFI_HANDLE in place of EFI_HII_HANDLELaszlo Ersek2019-10-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The UefiShell*CommandsLib instances have constructor functions that do something like: gHiiHandle = HiiAddPackages (...); ... ShellCommandRegisterCommandName (..., gHiiHandle, ...); and destructor functions that implement the following pattern: HiiRemovePackages (gHiiHandle); The -- semantic, not functional -- problem is that "gHiiHandle" is declared with type EFI_HANDLE, and not EFI_HII_HANDLE, in all of these library instances, even though HiiAddPackages() correctly returns EFI_HII_HANDLE, and HiiRemovePackages() takes EFI_HII_HANDLE. Once we fix the type of "gHiiHandle", it causes sort of a butterfly effect, because it is passed around widely. Track down and update all of those locations. The DynamicCommand lib instances use a similar pattern, so they are affected too. NOTE: in practice, this patch is a no-op, as both EFI_HII_HANDLE and EFI_HANDLE are typedefs to (VOID*). However, we shouldn't use EFI_HANDLE where semantically EFI_HII_HANDLE is passed around. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/UefiShellLib: Set input pointer parameter to null if failureBret Barkelew2019-07-011-0/+5
| | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1906 While failed to allocate memory to save the response, set the input/output parameter 'Response'(VOID **) to NULL to indicate the failure not only depend on the returned status. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Michael Turner <Michael.Turner@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
* ShellPkg: Replace BSD License with BSD+Patent LicenseMichael D Kinney2019-04-091-7/+1
| | | | | | | | | | | | | | | | | | | | | 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/UefiShellLib: Use BaseLib api CharToUpperShenglei Zhang2019-01-311-30/+3
| | | | | | | | | | | | | | | | Substitute InternalShellCharToUpper with CharToUpper which is a public function with the same effect. Remove the implement of InternalShellCharToUpper. https://bugzilla.tianocore.org/show_bug.cgi?id=1369 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/ShellLib: Fix potential NULL deference issueRuiyu Ni2018-11-081-1/+5
| | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1310 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jim Dailey <jim_dailey@dell.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg-UefiShellLib: Add a function to fully-qualify pathsJim.Dailey@dell.com2018-11-051-1/+116
| | | | | | | | | | | | | | | | | | | | | | Add a function to return a clean, fully-qualified version of some path. This function handles a (possibly "dirty") input path that may or may not include a file system reference. If it does not include a file system reference, then if the input path does not begin with a forward or backward slash, then the input path is relative to the current working directory of the current file system. Otherwise, it is an absolute path within the current file system. If it does include a file system reference, it may be a reference to the current or some other file system. If the file system reference is not immediately followed by a forward or backward slash, then the input path is relative to the current working directory of the given file system. Otherwise, it is an absolute path within the given file system. 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/UefiShellLib: rebase ShellOpenFileByDevicePath() to UefiLib APILaszlo Ersek2018-08-161-110/+3
| | | | | | | | | | | | | | | | | | | | | Replace the "old shell method" implementation in ShellOpenFileByDevicePath() with EfiOpenFileByDevicePath() from UefiLib, correcting the following issues: - code duplication between this module and other modules, - local variable name "EfiSimpleFileSystemProtocol" starting with "Efi" prefix, - bogus "FileHandle = NULL" assignments, - leaking "Handle1" when the device path type/subtype check or the realignment-motivated AllocateCopyPool() fails in the loop. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1008 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
* ShellPkg/UefiShellLib: drop DeviceHandle param of ShellOpenFileByDevicePath()Laszlo Ersek2018-08-161-7/+4
| | | | | | | | | | | | | | | | | | | | | The ShellOpenFileByDevicePath() API promises to set the DeviceHandle output parameter to the handle of the filesystem identified by the FilePath input parameter. However, this doesn't actually happen when the UEFI Shell 2.0 method is used (which is basically "always" nowadays). Accordingly, the only caller of ShellOpenFileByDevicePath(), namely ShellOpenFileByName(), defines a (dummy) local DeviceHandle variable just so it can call ShellOpenFileByDevicePath(). Remove the useless output parameter. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1008 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
* ShellPkg: Clean up source filesLiming Gao2018-06-281-36/+36
| | | | | | | | | | 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/ShellLib: Fix a bug in InternalShellIsHexOrDecimalNumberRuiyu Ni2018-02-151-8/+15
| | | | | | | | | | | | InternalShellIsHexOrDecimalNumber() wrongly treats "-" as a number. The patch fixes this issue. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=730 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg/ShellLib: Fix dynamic command fails to start during bootRuiyu Ni2017-11-291-37/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous change in ShellLib: "commit 3d29f8c5e361525a0d2accfa7f5bb0a7210b8927 * ShellPkg/ShellLib: Constructor doesn't depend on ShellParameters" resolved the issue when loading dynamic command driver from Shell environment. But when dynamic command driver is built into FV and started during boot, the driver still fails to start because Shell protocol doesn't exist at that time. The patch changes ShellLib to: 1. Do not look for Shell and ShellParameters protocol when they are non-NULL in ShellLibConstructorWorker(); The two protocols are assumed to be set by DynamicCommand.Handler. When ShellInitialize() is called in DynamicCommand.Handler, this change can prevent the two protocols to be changed to NULL by the locating logic. 2. Do not reset the Shell and ShellParameters protocol to NULL in ShellLibDestructor() when CloseProtocol() fails; Dynamic command driver needs to set the PcdShellLibAutoInitialize to FALSE in order to skip the constructor. Current logic calls ShellLibDestructor() when the PCD is FALSE when ShellInitialize() is called. The change prevent the two protocols to be changed to NULL. The two changes don't impact existing usage case so they are backward compatible. 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/ShellLib: Constructor doesn't depend on ShellParametersRuiyu Ni2017-11-281-4/+8
| | | | | | | | | | | | | When ShellLib is linked to a driver producing DynamicCommand protocol, ShellParameters protocol is set by DynamicCommand.Handler(). The driver image handle doesn't have ShellParameters protocol installed. Contributed-under: TianoCore Contribution Agreement 1.1 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>
* ShellPkg: Fix MSFT C4255 warningSong, BinX2017-11-141-0/+1
| | | | | | | | | | | | | | | | | | | 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/UefiShellLib: Use a more bright blue/green colorRuiyu Ni2017-10-171-2/+2
| | | | | | | | | | | Some developers/QAs complain the color of directory or executable files is hard to see and suggest to use a more bright color. I agree with this suggestion so make this patch. The look and feel is much better now. 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/ShellLib: Remove unused macrosRuiyu Ni2017-07-271-2/+0
| | | | | | | | | | MAX_FILE_NAME_LEN and FIND_XXXXX_FILE_BUFFER_SIZE are not used by ShellLib so remove them. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* ShellPkg/UefiShellLib: Check correct variable for NULLJeff Westfahl2017-06-021-1/+1
| | | | | | | | Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jaben Carsey <jaben.carsey@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg/UefiShellLib: Avoid reading undefined content before stringHao Wu2017-05-241-1/+1
| | | | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=566 In function InternalShellPrintWorker(), if the string in variable 'mPostReplaceFormat2' starts with character L'%', the following expression: *(ResumeLocation-1) == L'^' at line 2831 will read an undefined value before the starting of string 'mPostReplaceFormat2'. This commit adds additional logic to avoid reading undefined content. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: Refine casting expression result to bigger sizeHao Wu2017-03-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are cases that the operands of an expression are all with rank less than UINT64/INT64 and the result of the expression is explicitly cast to UINT64/INT64 to fit the target size. An example will be: UINT32 a,b; // a and b can be any unsigned int type with rank less than UINT64, like // UINT8, UINT16, etc. UINT64 c; c = (UINT64) (a + b); Some static code checkers may warn that the expression result might overflow within the rank of "int" (integer promotions) and the result is then cast to a bigger size. The commit refines codes by the following rules: 1). When the expression is possible to overflow the range of unsigned int/ int: c = (UINT64)a + b; 2). When the expression will not overflow within the rank of "int", remove the explicit type casts: c = a + b; 3). When the expression will be cast to pointer of possible greater size: UINT32 a,b; VOID *c; c = (VOID *)(UINTN)(a + b); --> c = (VOID *)((UINTN)a + b); 4). When one side of a comparison expression contains only operands with rank less than UINT32: UINT8 a; UINT16 b; UINTN c; if ((UINTN)(a + b) > c) {...} --> if (((UINT32)a + b) > c) {...} For rule 4), if we remove the 'UINTN' type cast like: if (a + b > c) {...} The VS compiler will complain with warning C4018 (signed/unsigned mismatch, level 3 warning) due to promoting 'a + b' to type 'int'. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: print only valid characters for file overwrite promptTapan Shah2016-10-311-2/+7
| | | | | | | | | | When copy command prompts to overwrite an existing file, pressing backspace continuously removes everything including the shell prompt. So print only valid characters for file overwrite prompt. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Tapan Shah <tapandshah@hpe.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: Update sources to include MdePkg protocol definitionsRuiyu Ni2016-10-191-1/+0
| | | | | | Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg/UefiShellLib: Remove unnecessary EFIAPIChen A Chen2016-10-091-14/+0
| | | | | | | 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> Reviewed-by: Ruiyu Ni <Ruiyu.ni@intel.com>
* ShellPkg: Fix erroneous Status returned by ShellOpenFileByName()Vladimir Olovyannikov2016-10-071-0/+3
| | | | | | | | | | | | | | | | | | | | In ShellOpenFileByName() the file is opened using gEfiShellProtocol->OpenFileByName(). It is supposed that if this call returns an EFI_ERROR, the function should return that error immediately. However, this return was missing, and if UnicodeCollationProtocol has not been located by this time, the Status gets overwritten with LocateProtocol() call result, which eventually erroneously returns EFI_SUCCESS to the Shell.c, and this leads to attempt to execute a non-existent startup script, which fails, and which in turn leads to Shell being unloaded with "Invalid parameter" error. This patch fixes the bug. Cc: Tapan Shah <tapandshah@hpe.com> Cc: Jaben Carsey <jaben.carsey@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com> Reviewed-by: Tapan Shah <tapandshah@hpe.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: Move UnicodeCollation2 Protcol locate out of UefiShellLib constructorTapan Shah2016-10-051-7/+9
| | | | | | | | | | | Move gEfiUnicodeCollation2ProtocolGuid protocol outside of UefiShellLib constructor function. Locate gEfiUnicodeCollation2ProtocolGuid protocol in ShellOpenFileByName() which consumes this protocol API. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Tapan Shah <tapandshah@hpe.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: Expand special output file to include "NULL" and case insensitiveTapan Shah2016-09-221-1/+13
| | | | | | | | | | | | As per ECR 1349 change in UEFI Shell Specification 2.2, expanding a special output file name to include "NULL". Previously it only supported "NUL" as a special output file and it was case sensitive. With this change both "NUL" and "NULL" are special output file and checked as case insensitive. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Tapan Shah <tapandshah@hpe.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg/UefiShellLib.c: Handle memory allocation failureRuiyu Ni2016-07-181-5/+6
| | | | | | Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg/UefiShellLib: Handle memory allocation failureRuiyu Ni2016-07-181-2/+10
| | | | | | Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: Series of patches to fix typos - apropriate to appropriateMudusuru, Giri P2016-07-071-1/+1
| | | | | | | | Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Shumin Qiu <shumin.qiu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Giri P Mudusuru <giri.p.mudusuru@intel.com> Reviewed-By: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: don't call functions with side effects in ASSERT_EFI_ERROR()Laszlo Ersek2016-06-301-1/+4
| | | | | | | | | | | | When ASSERT_EFI_ERROR() is compiled out, dependent on build flags, only the status checking should be removed; the function calls should stay. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Shumin Qiu <shumin.qiu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Giri P Mudusuru <giri.p.mudusuru@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: Do NULL pointer check before the pointer is used.Qiu Shumin2016-02-231-1/+1
| | | | | | | | Do NULL pointer check before the pointer is used to avoid dereferenced. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin <shumin.qiu@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: Fix the last command doesn't work in a script.Qiu Shumin2016-02-191-1/+4
| | | | | | | | | | When the last line in a script file is not an empty line the Shell will not execute the command in the last line. The patch refine the logic in function 'ShellFileHandleReturnLine' and fix the issue. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>
* ShellPkg: complete previous incomplete patchJim Dailey2016-02-101-29/+13
| | | | | | Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jim Dailey <Jim_Dailey@Dell.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* Merge branch 'master' of https://github.com/tianocore/edk2Jaben Carsey2016-02-101-13/+29
|\
| * ShellPkg: Fix ASCII and UNICODE file pipes.jaben carsey2016-02-081-18/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix various errors when piping a UNICODE or ASCII file to a simple shell application that reads standard input and writes it to standard output. 1) When the memory file is created by CreateFileInferfaceMem() to capture the pipe output, no UNICODE BOM is written to the memory file. Later, when the memory file is read by the application using ShellFileHandleReadLine(), the function indicates that the file is ASCII because there is no BOM. 2) If the file is piped as ASCII, the ASCII memory image is not correctly created by FileInterfaceMemWrite() as each ASCII character is followed by '\0' in the image (when the ASCII data is written to the memory image, the file position should only be incremented by half the buffer size). 3) ShellFileHandleReadLine() does not read ASCII files correctly (writes to Buffer need to be cast as CHAR8*). 4) FileInterfaceMemRead() and FileInterfaceMemWrite() as somewhat hard to read and difficult to debug with certain tools due to the typecasting of This. Added a local variable (MemFile) of the correct type to these functions and used it instead of This. Enhancement: ShellFileHandleReadLine() now returns EFI_END_OF_FILE when appropriate. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jim Dailey <jim_dailey@dell.com> reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* | ShellPkg: ShellFileHandleReadLine must return UCS2 lines.Jim Dailey2016-02-101-31/+26
| | | | | | | | | | | | | | | | | | | | | | | | An earlier change had this function returning the type of lines that were in the file being read (ASCII or UCS2). The way it is used, UCS2 output is expected, even when the file being read is ASCII. This change restores that behavior and documents it. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jim Dailey <Jim_Dailey@Dell.com> Tested-by: Ryan Harkin <ryan.harkin@linaro.org> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* | ShellPkg: Fix ASCII and UNICODE file pipes.jaben carsey2016-02-091-18/+39
|/ | | | | | | | | | | | | | | | | | Fix various errors when piping a UNICODE or ASCII file to a simple shell application that reads standard input and writes it to standard output. 1) When the memory file is created by CreateFileInferfaceMem() to capture the pipe output, no UNICODE BOM is written to the memory file. Later, when the memory file is read by the application using ShellFileHandleReadLine(), the function indicates that the file is ASCII because there is no BOM. 2) If the file is piped as ASCII, the ASCII memory image is not correctly created by FileInterfaceMemWrite() as each ASCII character is followed by '\0' in the image (when the ASCII data is written to the memory image, the file position should only be incremented by half the buffer size). 3) ShellFileHandleReadLine() does not read ASCII files correctly (writes to Buffer need to be cast as CHAR8*). 4) FileInterfaceMemRead() and FileInterfaceMemWrite() as somewhat hard to read and difficult to debug with certain tools due to the typecasting of This. Added a local variable (MemFile) of the correct type to these functions and used it instead of This. Enhancement: ShellFileHandleReadLine() now returns EFI_END_OF_FILE when appropriate. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jim Dailey <jim_dailey@dell.com> reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: Fix memory leak in 'ShellOpenFileByName'.Yao Jiewen2015-12-251-1/+6
| | | | | | | | Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yao Jiewen <Jiewen.Yao@intel.com> Reviewed-by: Qiu Shumin <shumin.qiu@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19524 6f19259b-4bc3-4df7-8a09-765794883524
* ShellPkg: Follow spec to remove the last '\' char in return name of GetCurDir().Qiu Shumin2015-10-231-1/+4
| | | | | | | | | | | | | | | | | | In Shell spec 2.1 the return name of EFI_SHELL_PROTOCOL.GetCurDir() is defined as 'fs0:\current-dir' while in current implementation it's 'fs0:\current-dir\'. To follow spec the patch removed the redundant '\' char. Since it has been broken for a long time, some codes may depend on the broken behavior. After this change 'EFI_SHELL_PROTOCOL.GetCurDir()' and 'UefiShellLib.ShellGetCurrentDir()' will return a current directory string without tailing '\' (fs0:\current-dir), the value of Shell environment variable 'cwd' will become 'fs0:\current-dir' as well. This patch has updated all the code in EDKII to make them depend on the new behavior. Developers should check whether 'GetCurDir()' and 'ShellGetCurrentDir' are used in their source code. 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@18653 6f19259b-4bc3-4df7-8a09-765794883524
* ShellPkg: prevent Close call when Open failedJaben Carsey2015-07-281-2/+3
| | | | | | | | | Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Tapan Shah <tapandshah@hp.com> Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18096 6f19259b-4bc3-4df7-8a09-765794883524
* ShellPkg: Fix typo of 'determines' in ShellPkg.Bruce Cran2015-07-081-1/+1
| | | | | | | | Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Bruce Cran <bruce@cran.org.uk> Reviewed-by: Qiu Shumin <shumin.qiu@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17868 6f19259b-4bc3-4df7-8a09-765794883524
* ShellPkg: fix string to number conversion with "0 "Jaben Carsey2015-07-021-9/+12
| | | | | | | | | | | also fixes a few out of date comments. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Tapan Shah <tapandshah@hp.com> Reviewed-by: Qiu Shumin <shumin.qiu@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17816 6f19259b-4bc3-4df7-8a09-765794883524
* ShellPkg: Refine the code logic of StrnCatGrow.Qiu Shumin2015-07-021-2/+3
| | | | | | | | | | | In order to indicate the catena length use StrnCatS instead of StrCatS to generate Destination string, and update the DestMax of Destination string. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin <shumin.qiu@intel.com> Reviewed-by: Tapan Shah <tapandshah@hp.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17795 6f19259b-4bc3-4df7-8a09-765794883524
* ShellPkg: Use safe string functions to refine code.Qiu Shumin2015-06-301-12/+23
| | | | | | | | | | Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin <shumin.qiu@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17730 6f19259b-4bc3-4df7-8a09-765794883524
* ShellPkg: Remove extra quotes surrounding flag values.Qiu Shumin2015-04-011-28/+9
| | | | | | | | | 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@17086 6f19259b-4bc3-4df7-8a09-765794883524
* ShellPkg: Add type cast to avoid build failure in VS2005.Qiu Shumin2015-03-131-1/+1
| | | | | | | | | | 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@17043 6f19259b-4bc3-4df7-8a09-765794883524
* ShellPkg/UefiShellLib: Fixed ARM compiler errorOlivier Martin2015-02-231-1/+1
| | | | | | | | | | | | | | | | | ARM Compiler version 5 raises the warning/error (warning treated as error): #191-D: type qualifier is meaningless on cast type The compiler team said the warning is valid because from the C90 standard, section 6.5.3 it is specified that "The properties associated with qualified types are meaningful only for expressions that are lvalues." Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16888 6f19259b-4bc3-4df7-8a09-765794883524