From c4d125f22d34dfa589509abd0103404a7ab2a222 Mon Sep 17 00:00:00 2001 From: Nicholas Yip Date: Thu, 3 Dec 2020 01:55:49 +0900 Subject: [PATCH] feat(option): Restrict the timeout input to non-negative integers --- wait-for | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wait-for b/wait-for index e28e54c..a685a69 100755 --- a/wait-for +++ b/wait-for @@ -55,7 +55,6 @@ do ;; -t) TIMEOUT="$2" - if [ "$TIMEOUT" = "" ]; then break; fi shift 2 ;; --timeout=*) @@ -76,6 +75,11 @@ do esac done +if ! [ "$TIMEOUT" -ge 0 ] 2>/dev/null; then + echoerr "Error: invalid timeout '$TIMEOUT'" + usage 3 +fi + if [ "$HOST" = "" -o "$PORT" = "" ]; then echoerr "Error: you need to provide a host and port to test." usage 2