Skip to content

Commit 6566463

Browse files
Lhuckazikatz-drizly
authored andcommitted
Add strict option
1 parent 1e47fb8 commit 6566463

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

wait-for

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ usage() {
2323
Usage:
2424
$cmdname host:port [-t timeout] [-- command args]
2525
-q | --quiet Do not output any status messages
26+
-s | --strict Only execute subcommand if the test succeeds
2627
-t TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout
2728
-- COMMAND ARGS Execute command with args after the test finishes
2829
USAGE
@@ -43,6 +44,12 @@ wait_for() {
4344
sleep 1
4445
done
4546
echo "Operation timed out" >&2
47+
if [ $result -ne 0 ] && [ $STRICT -ne 1 ] ; then
48+
if [ $# -gt 0 ] ; then
49+
exec "$@"
50+
fi
51+
exit 0
52+
fi
4653
exit 1
4754
}
4855

@@ -58,6 +65,10 @@ do
5865
QUIET=1
5966
shift 1
6067
;;
68+
-s | --strict)
69+
STRICT=1
70+
shift 1
71+
;;
6172
-t)
6273
TIMEOUT="$2"
6374
if [ "$TIMEOUT" = "" ]; then break; fi
@@ -86,4 +97,6 @@ if [ "$HOST" = "" -o "$PORT" = "" ]; then
8697
usage 2
8798
fi
8899

100+
STRICT=${STRICT:-0}
101+
89102
wait_for "$@"

0 commit comments

Comments
 (0)