Skip to content

Commit 5fc2194

Browse files
author
Douglas Gibbons
authored
Merge pull request #90 from krufab/busybox-timeout-update-fix
Added support for new busybox timeout version
2 parents 54d1f0b + ed77b63 commit 5fc2194

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

wait-for-it.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Use this script to test if a given TCP host/port are available
2+
# Use this script to test if a given TCP host/port are available
33

44
WAITFORIT_cmdname=${0##*/}
55

@@ -141,16 +141,20 @@ WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
141141
WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
142142
WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}
143143

144-
# check to see if timeout is from busybox?
144+
# Check to see if timeout is from busybox?
145145
WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
146146
WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
147+
148+
WAITFORIT_BUSYTIMEFLAG=""
147149
if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
148-
WAITFORIT_ISBUSY=1
150+
WAITFORIT_ISBUSY=1
151+
# Check if busybox timeout uses -t flag
152+
# (recent Alpine versions don't support -t anymore)
153+
if timeout &>/dev/stdout | grep -q -e '-t '; then
149154
WAITFORIT_BUSYTIMEFLAG="-t"
150-
155+
fi
151156
else
152-
WAITFORIT_ISBUSY=0
153-
WAITFORIT_BUSYTIMEFLAG=""
157+
WAITFORIT_ISBUSY=0
154158
fi
155159

156160
if [[ $WAITFORIT_CHILD -gt 0 ]]; then

0 commit comments

Comments
 (0)