Skip to content

Commit b123349

Browse files
committed
fix: Add attribution
1 parent 60be514 commit b123349

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

wait-for

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
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

610
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
812
}
913

1014
usage() {
@@ -20,8 +24,8 @@ USAGE
2024
}
2125

2226
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
2529

2630
result=$?
2731
if [ $result -eq 0 ] ; then
@@ -40,21 +44,21 @@ while [ $# -gt 0 ]
4044
do
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
--)
@@ -71,7 +75,7 @@ do
7175
esac
7276
done
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
7781
fi

0 commit comments

Comments
 (0)