File tree 1 file changed +16
-12
lines changed
1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
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
5
9
6
10
echoerr () {
7
- if [ " $QUIET " -ne 1 ]; then printf " %s\n" " $* " 1>&2 ; fi
11
+ if [ " $quiet " -ne 1 ]; then printf " %s\n" " $* " 1>&2 ; fi
8
12
}
9
13
10
14
usage () {
20
24
}
21
25
22
26
wait_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
25
29
26
30
result=$?
27
31
if [ $result -eq 0 ] ; then
@@ -40,21 +44,21 @@ while [ $# -gt 0 ]
40
44
do
41
45
case " $1 " in
42
46
* :* )
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)
45
49
shift 1
46
50
;;
47
51
-q | --quiet)
48
- QUIET =1
52
+ quiet =1
49
53
shift 1
50
54
;;
51
55
-t)
52
- TIMEOUT =" $2 "
53
- if [ " $TIMEOUT " = " " ]; then break ; fi
56
+ timeout =" $2 "
57
+ if [ " $timeout " = " " ]; then break ; fi
54
58
shift 2
55
59
;;
56
60
--timeout=* )
57
- TIMEOUT =" ${1#* =} "
61
+ timeout =" ${1#* =} "
58
62
shift 1
59
63
;;
60
64
--)
71
75
esac
72
76
done
73
77
74
- if [ " $HOST " = " " -o " $PORT " = " " ]; then
78
+ if [ " $host " = " " -o " $port " = " " ]; then
75
79
echoerr " Error: you need to provide a host and port to test."
76
80
usage 2
77
81
fi
You can’t perform that action at this time.
0 commit comments