File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -30,11 +30,21 @@ USAGE
3030 exit " $exitcode "
3131}
3232
33+ test_connection () {
34+ # force a 1-second timeout on darwin (https://stackoverflow.com/a/20460402/2063546)
35+ # POSIX-compliant string inclusion test https://stackoverflow.com/a/8811800/2063546
36+ if [ " ${OSTYPE#* darwin* } " != " $OSTYPE " ] ; then
37+ nc -z -w 1 -G 1 " $1 " " $2 "
38+ else
39+ nc -z -w 1 " $1 " " $2 " > /dev/null 2>&1
40+ fi
41+ }
42+
3343wait_for () {
3444 for i in ` seq $TIMEOUT ` ; do
35- # use a 1-second timeout
36- nc -w 1 -z " $HOST " " $PORT " > /dev/null 2>&1
37-
45+ # use a 1-second timeout, but still sleep 0.1 seconds after just to be safe
46+ test_connection " $HOST " " $PORT "
47+
3848 result=$?
3949 if [ $result -eq 0 ] ; then
4050 if [ $# -gt 0 ] ; then
You can’t perform that action at this time.
0 commit comments