[edk2-devel] [PATCH] OvmfPkg/build.sh: use POSIX 'command -v' instead of 'which'.

rebecca@bsdio.com posted 1 patch 4 years, 8 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/edk2 tags/patchew/20190724004947.55202-1-rebecca@bsdio.com
OvmfPkg/build.sh | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
[edk2-devel] [PATCH] OvmfPkg/build.sh: use POSIX 'command -v' instead of 'which'.
Posted by rebecca@bsdio.com 4 years, 8 months ago
Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
---
 OvmfPkg/build.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/OvmfPkg/build.sh b/OvmfPkg/build.sh
index e94aa2a37e..1c28e65404 100755
--- a/OvmfPkg/build.sh
+++ b/OvmfPkg/build.sh
@@ -174,11 +174,11 @@ case $PROCESSOR in
       # The user set the QEMU_COMMAND variable. We'll use it to run QEMU.
       #
       :
-    elif  [ -x `which qemu-system-i386` ]; then
+    elif command -v qemu-system-i386; then
       QEMU_COMMAND=qemu-system-i386
-    elif  [ -x `which qemu-system-x86_64` ]; then
+    elif command -v qemu-system-x86_64; then
       QEMU_COMMAND=qemu-system-x86_64
-    elif  [ -x `which qemu` ]; then
+    elif command -v qemu; then
       QEMU_COMMAND=qemu
     else
       echo Unable to find QEMU for IA32 architecture!
@@ -242,12 +242,12 @@ FV_DIR=$BUILD_ROOT/FV
 BUILD_ROOT_ARCH=$BUILD_ROOT/$BUILD_ROOT_ARCH
 QEMU_FIRMWARE_DIR=$BUILD_ROOT/QEMU
 
-if  [[ ! -f `which build` || ! -f `which GenFv` ]];
+if ! command -v build || ! command -v GenFv;
 then
   # build the tools if they don't yet exist. Bin scheme
   echo Building tools as they are not in the path
   make -C $WORKSPACE/BaseTools
-elif [[ ( -f `which build` ||  -f `which GenFv` )  && ! -d  $EDK_TOOLS_PATH/Source/C/bin ]];
+elif [[ ( $(command -v build) || $(command -v GenFv) ) && ! -d $EDK_TOOLS_PATH/Source/C/bin ]];
 then
   # build the tools if they don't yet exist. BinWrapper scheme
   echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
-- 
2.22.0


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44273): https://edk2.groups.io/g/devel/message/44273
Mute This Topic: https://groups.io/mt/32579615/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH] OvmfPkg/build.sh: use POSIX 'command -v' instead of 'which'.
Posted by Philippe Mathieu-Daudé 4 years, 8 months ago
Hi Rebecca,

On 7/24/19 2:49 AM, rebecca@bsdio.com wrote:
> Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
> ---
>  OvmfPkg/build.sh | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/OvmfPkg/build.sh b/OvmfPkg/build.sh
> index e94aa2a37e..1c28e65404 100755
> --- a/OvmfPkg/build.sh
> +++ b/OvmfPkg/build.sh
> @@ -174,11 +174,11 @@ case $PROCESSOR in
>        # The user set the QEMU_COMMAND variable. We'll use it to run QEMU.
>        #
>        :
> -    elif  [ -x `which qemu-system-i386` ]; then
> +    elif command -v qemu-system-i386; then
>        QEMU_COMMAND=qemu-system-i386
> -    elif  [ -x `which qemu-system-x86_64` ]; then
> +    elif command -v qemu-system-x86_64; then
>        QEMU_COMMAND=qemu-system-x86_64
> -    elif  [ -x `which qemu` ]; then
> +    elif command -v qemu; then
>        QEMU_COMMAND=qemu
>      else
>        echo Unable to find QEMU for IA32 architecture!
> @@ -242,12 +242,12 @@ FV_DIR=$BUILD_ROOT/FV
>  BUILD_ROOT_ARCH=$BUILD_ROOT/$BUILD_ROOT_ARCH
>  QEMU_FIRMWARE_DIR=$BUILD_ROOT/QEMU
>  
> -if  [[ ! -f `which build` || ! -f `which GenFv` ]];
> +if ! command -v build || ! command -v GenFv;
>  then
>    # build the tools if they don't yet exist. Bin scheme
>    echo Building tools as they are not in the path
>    make -C $WORKSPACE/BaseTools
> -elif [[ ( -f `which build` ||  -f `which GenFv` )  && ! -d  $EDK_TOOLS_PATH/Source/C/bin ]];
> +elif [[ ( $(command -v build) || $(command -v GenFv) ) && ! -d $EDK_TOOLS_PATH/Source/C/bin ]];

Why add $() ?

>  then
>    # build the tools if they don't yet exist. BinWrapper scheme
>    echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
> 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44313): https://edk2.groups.io/g/devel/message/44313
Mute This Topic: https://groups.io/mt/32579615/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH] OvmfPkg/build.sh: use POSIX 'command -v' instead of 'which'.
Posted by rebecca@bsdio.com 4 years, 8 months ago
On 2019-07-24 06:30, Philippe Mathieu-Daudé wrote:
>
> Why add $() ?
>
>>  then
>>    # build the tools if they don't yet exist. BinWrapper scheme
>>    echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
>>

I've sent another copy of this patch, in the v2 series of
OvmfPkg/build.sh changes.


-- 
Rebecca Cran


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44339): https://edk2.groups.io/g/devel/message/44339
Mute This Topic: https://groups.io/mt/32579615/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH] OvmfPkg/build.sh: use POSIX 'command -v' instead of 'which'.
Posted by rebecca@bsdio.com 4 years, 8 months ago
On 2019-07-24 06:30, Philippe Mathieu-Daudé wrote:
>
>> -elif [[ ( -f `which build` ||  -f `which GenFv` )  && ! -d  $EDK_TOOLS_PATH/Source/C/bin ]];
>> +elif [[ ( $(command -v build) || $(command -v GenFv) ) && ! -d $EDK_TOOLS_PATH/Source/C/bin ]];
> Why add $() ?


They're needed when used in a test ([...] or [[...]]) statement. $()
replaces the older `` syntax.


-- 

Rebecca Cran


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44314): https://edk2.groups.io/g/devel/message/44314
Mute This Topic: https://groups.io/mt/32579615/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-