File tree Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change 11#! /bin/sh
22
3- TIMEOUT=15
4- QUIET=0
3+ # Just like https://github.com/eficode/wait-for/raw/master/wait-for, but
4+ # using more conventional lower-case for local variables (mostly so that
5+ # PORT doesn't get exported into whatever is being exec'd).
6+
7+ timeout=15
8+ quiet=0
59
610echoerr () {
7- if [ " $QUIET " -ne 1 ]; then printf " %s\n" " $* " 1>&2 ; fi
11+ if [ " $quiet " -ne 1 ]; then printf " %s\n" " $* " 1>&2 ; fi
812}
913
1014usage () {
2024}
2125
2226wait_for () {
23- for i in ` seq $TIMEOUT ` ; do
24- nc -z " $HOST " " $PORT " > /dev/null 2>&1
27+ for i in ` seq $timeout ` ; do
28+ nc -z " $host " " $port " > /dev/null 2>&1
2529
2630 result=$?
2731 if [ $result -eq 0 ] ; then
@@ -40,21 +44,21 @@ while [ $# -gt 0 ]
4044do
4145 case " $1 " in
4246 * :* )
43- HOST =$( printf " %s\n" " $1 " | cut -d : -f 1)
44- PORT =$( printf " %s\n" " $1 " | cut -d : -f 2)
47+ host =$( printf " %s\n" " $1 " | cut -d : -f 1)
48+ port =$( printf " %s\n" " $1 " | cut -d : -f 2)
4549 shift 1
4650 ;;
4751 -q | --quiet)
48- QUIET =1
52+ quiet =1
4953 shift 1
5054 ;;
5155 -t)
52- TIMEOUT =" $2 "
53- if [ " $TIMEOUT " = " " ]; then break ; fi
56+ timeout =" $2 "
57+ if [ " $timeout " = " " ]; then break ; fi
5458 shift 2
5559 ;;
5660 --timeout=* )
57- TIMEOUT =" ${1#* =} "
61+ timeout =" ${1#* =} "
5862 shift 1
5963 ;;
6064 --)
7175 esac
7276done
7377
74- if [ " $HOST " = " " -o " $PORT " = " " ]; then
78+ if [ " $host " = " " -o " $port " = " " ]; then
7579 echoerr " Error: you need to provide a host and port to test."
7680 usage 2
7781fi
You can’t perform that action at this time.
0 commit comments