From 902bdf3d92fbebae2a8beb54150b9460f202aa62 Mon Sep 17 00:00:00 2001 From: a1346054 <36859588+a1346054@users.noreply.github.com> Date: Mon, 12 Sep 2022 23:24:26 +0000 Subject: [PATCH] Use bash-builtin `command -v` instead of external `which` `command -v` is a bash builtin and is a standardized version of `which` --- utils/checkcert.sh | 2 +- utils/curves.bash | 2 +- utils/generate_static_cipher_lists.sh | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/checkcert.sh b/utils/checkcert.sh index c86097a..79c63cd 100755 --- a/utils/checkcert.sh +++ b/utils/checkcert.sh @@ -74,7 +74,7 @@ datebanner() { dns() { ip4=`host -t a $1 | grep -v alias | sed 's/^.*address //'` - which getent 2>&1 >/dev/null && getent ahostsv4 $1 2>&1 >/dev/null && ip4=`getent ahostsv4 $1 | awk '{ print $1}' | uniq` + command -v getent 2>&1 >/dev/null && getent ahostsv4 $1 2>&1 >/dev/null && ip4=`getent ahostsv4 $1 | awk '{ print $1}' | uniq` NODEIP=`echo "$ip4" | head -1` rDNS=`host -t PTR $NODEIP | sed -e 's/^.*pointer //' -e 's/\.$//'` echo $rDNS | grep -q NXDOMAIN && rDNS="" diff --git a/utils/curves.bash b/utils/curves.bash index 8a8f76b..2a00f63 100755 --- a/utils/curves.bash +++ b/utils/curves.bash @@ -36,7 +36,7 @@ find_openssl_binary() { : # 2. otherwise try openssl in path of testssl.sh elif test_openssl_suffix ../$RUN_DIR/bin; then : # 3. otherwise here, this is supposed to be the standard --platform independent path in the future!!! - elif test_openssl_suffix "$(dirname "$(which openssl)")"; then + elif test_openssl_suffix "$(dirname "$(command -v openssl)")"; then : # 5. we tried hard and failed, so now we use the system binaries fi diff --git a/utils/generate_static_cipher_lists.sh b/utils/generate_static_cipher_lists.sh index 6e4a8e8..85d747c 100755 --- a/utils/generate_static_cipher_lists.sh +++ b/utils/generate_static_cipher_lists.sh @@ -67,7 +67,7 @@ get_mapping_file() { fi # we haven't found the cipher file yet... - if [[ ! -r "$CIPHERS_BY_STRENGTH_FILE" ]] && which readlink &>/dev/null ; then + if [[ ! -r "$CIPHERS_BY_STRENGTH_FILE" ]] && command -v readlink &>/dev/null ; then readlink -f ls &>/dev/null && \ TESTSSL_INSTALL_DIR=$(readlink -f $(basename ${BASH_SOURCE[0]})) || \ TESTSSL_INSTALL_DIR=$(readlink $(basename ${BASH_SOURCE[0]})) @@ -78,14 +78,14 @@ get_mapping_file() { fi # still no cipher mapping file: - if [[ ! -r "$CIPHERS_BY_STRENGTH_FILE" ]] && which realpath &>/dev/null ; then + if [[ ! -r "$CIPHERS_BY_STRENGTH_FILE" ]] && command -v realpath &>/dev/null ; then TESTSSL_INSTALL_DIR=$(dirname $(realpath ${BASH_SOURCE[0]})) CIPHERS_BY_STRENGTH_FILE="$TESTSSL_INSTALL_DIR/etc/cipher-mapping.txt" [[ -r "$TESTSSL_INSTALL_DIR/cipher-mapping.txt" ]] && CIPHERS_BY_STRENGTH_FILE="$TESTSSL_INSTALL_DIR/cipher-mapping.txt" fi # still no cipher mapping file (and realpath is not present): - if [[ ! -r "$CIPHERS_BY_STRENGTH_FILE" ]] && which readlink &>/dev/null ; then + if [[ ! -r "$CIPHERS_BY_STRENGTH_FILE" ]] && command -v readlink &>/dev/null ; then readlink -f ls &>/dev/null && \ TESTSSL_INSTALL_DIR=$(dirname $(readlink -f ${BASH_SOURCE[0]})) || \ TESTSSL_INSTALL_DIR=$(dirname $(readlink ${BASH_SOURCE[0]}))