From 1e226263db10dbfeb88c5636a25e296e3d7bc8b2 Mon Sep 17 00:00:00 2001 From: David Vazquez Date: Sun, 18 Oct 2015 12:00:58 +0200 Subject: [PATCH] Do not rely on `which` to be present in the system For portability, it is better to use the built-in `command` to check the existance of executables in the system. --- doc/manual/make-tempfiles.sh | 2 +- find-gnumake.sh | 4 ++-- generate-version.sh | 2 +- make-target-contrib.sh | 2 +- tests/run-compiler.sh | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/manual/make-tempfiles.sh b/doc/manual/make-tempfiles.sh index ec07a3f35..b389c973e 100644 --- a/doc/manual/make-tempfiles.sh +++ b/doc/manual/make-tempfiles.sh @@ -27,7 +27,7 @@ then SBCL_HOME=$SBCL_PWD/../../obj/sbcl-home/; export SBCL_HOME SBCL_BUILDING_CONTRIB="please asdf install your hook"; export SBCL_BUILDING_CONTRIB else - SBCLRUNTIME="`which sbcl`" + SBCLRUNTIME="`command -v sbcl`" fi else SBCLRUNTIME="$1" diff --git a/find-gnumake.sh b/find-gnumake.sh index f5cf67682..cb2c486c1 100644 --- a/find-gnumake.sh +++ b/find-gnumake.sh @@ -8,10 +8,10 @@ find_gnumake() { GNUMAKE="$GNUMAKE" elif [ "GNU Make" = "`make -v 2>/dev/null | head -n 1 | cut -b 1-8`" ]; then GNUMAKE=make - elif [ -x "`which gmake`" ] ; then + elif [ -x "`command -v gmake`" ] ; then # "gmake" is the preferred name in *BSD. GNUMAKE=gmake - elif [ -x "`which gnumake`" ] ; then + elif [ -x "`command -v gnumake`" ] ; then # MacOS X aka Darwin GNUMAKE=gnumake else diff --git a/generate-version.sh b/generate-version.sh index 94837cb11..f51b46710 100755 --- a/generate-version.sh +++ b/generate-version.sh @@ -2,7 +2,7 @@ git_available_p() { # Check that (1) we have git (2) this is a git tree. - if ( which git >/dev/null 2>/dev/null && git describe >/dev/null 2>/dev/null ) + if ( command -v git >/dev/null && git describe >/dev/null 2>/dev/null ) then echo "ok" else diff --git a/make-target-contrib.sh b/make-target-contrib.sh index 71f0a3f61..02233cec5 100755 --- a/make-target-contrib.sh +++ b/make-target-contrib.sh @@ -22,7 +22,7 @@ LC_ALL=C # Just doing CC=${CC:-cc} may be enough, but it needs to be checked # that cc is available on all platforms. if [ -z $CC ]; then - if [ -x "`which cc`" ]; then + if [ -x "`command -v cc`" ]; then CC=cc else CC=gcc diff --git a/tests/run-compiler.sh b/tests/run-compiler.sh index 4b38df805..e5f549eaf 100755 --- a/tests/run-compiler.sh +++ b/tests/run-compiler.sh @@ -3,7 +3,7 @@ platform="${SBCL_SOFTWARE_TYPE}-${SBCL_MACHINE_TYPE}" if [ -z $CC ]; then - if [ -x "`which cc`" ]; then + if [ -x "`command -v cc`" ]; then CC=cc else CC=gcc