From f9a0dc44d38e04d2f8fbcd517d6c202682e896c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 1 Nov 2017 09:03:33 +0200 Subject: [PATCH 1/3] Use type -p instead of which --- wait-for-it.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wait-for-it.sh b/wait-for-it.sh index bbe4043..5cef902 100755 --- a/wait-for-it.sh +++ b/wait-for-it.sh @@ -142,8 +142,7 @@ CHILD=${CHILD:-0} QUIET=${QUIET:-0} # check to see if timeout is from busybox? -# check to see if timeout is from busybox? -TIMEOUT_PATH=$(realpath $(which timeout)) +TIMEOUT_PATH=$(realpath $(type -p timeout)) if [[ $TIMEOUT_PATH =~ "busybox" ]]; then ISBUSY=1 BUSYTIMEFLAG="-t" From 5fe30e7a26be72db05c142300dbbc895ab3a7630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 1 Nov 2017 09:05:58 +0200 Subject: [PATCH 2/3] Use parameter expansion instead of basename --- wait-for-it.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wait-for-it.sh b/wait-for-it.sh index 5cef902..cfe051c 100755 --- a/wait-for-it.sh +++ b/wait-for-it.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Use this script to test if a given TCP host/port are available -cmdname=$(basename $0) +cmdname=${0##*/} echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } From 019f3bb5bcf6fd16015badc63dcfa007a52597f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sat, 30 Dec 2017 09:25:54 +0200 Subject: [PATCH 3/3] Fall back to readlink -f if realpath is not available or fails --- wait-for-it.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wait-for-it.sh b/wait-for-it.sh index cfe051c..eb722b0 100755 --- a/wait-for-it.sh +++ b/wait-for-it.sh @@ -142,7 +142,8 @@ CHILD=${CHILD:-0} QUIET=${QUIET:-0} # check to see if timeout is from busybox? -TIMEOUT_PATH=$(realpath $(type -p timeout)) +TIMEOUT_PATH=$(type -p timeout) +TIMEOUT_PATH=$(realpath $TIMEOUT_PATH 2>/dev/null || readlink -f $TIMEOUT_PATH) if [[ $TIMEOUT_PATH =~ "busybox" ]]; then ISBUSY=1 BUSYTIMEFLAG="-t"