Skip to content

Commit 4c63495

Browse files
committed
Exit with 0 and output usage to stdout with --help
1 parent db04971 commit 4c63495

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

wait-for-it.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
77

88
usage()
99
{
10-
cat << USAGE >&2
10+
[[ $1 ]] && out=2 || out=1
11+
cat << USAGE >&$out
1112
Usage:
1213
$cmdname host:port [-s] [-t timeout] [-- command args]
1314
-h HOST | --host=HOST Host or IP under test
@@ -19,7 +20,7 @@ Usage:
1920
Timeout in seconds, zero for no timeout
2021
-- COMMAND ARGS Execute command with args after the test finishes
2122
USAGE
22-
exit 1
23+
exit ${1:-0}
2324
}
2425

2526
wait_for()
@@ -126,14 +127,14 @@ do
126127
;;
127128
*)
128129
echoerr "Unknown argument: $1"
129-
usage
130+
usage 1
130131
;;
131132
esac
132133
done
133134

134135
if [[ "$HOST" == "" || "$PORT" == "" ]]; then
135136
echoerr "Error: you need to provide a host and port to test."
136-
usage
137+
usage 1
137138
fi
138139

139140
TIMEOUT=${TIMEOUT:-15}

0 commit comments

Comments
 (0)