From 450058159d23b2d1c961dc2434f3c170c1e49784 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 3 Feb 2020 16:08:25 +0100 Subject: [PATCH] add check for installed netcat --- wait-for | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wait-for b/wait-for index ddfc39e..7677dc3 100755 --- a/wait-for +++ b/wait-for @@ -22,7 +22,7 @@ USAGE wait_for() { for i in `seq $TIMEOUT` ; do nc -z "$HOST" "$PORT" > /dev/null 2>&1 - + result=$? if [ $result -eq 0 ] ; then if [ $# -gt 0 ] ; then @@ -71,6 +71,11 @@ do esac done +if ! [ -x "$(command -v nc)" ]; then + echoerr "Error: netcat is required for wait-for to run." + exit 1 +fi + if [ "$HOST" = "" -o "$PORT" = "" ]; then echoerr "Error: you need to provide a host and port to test." usage 2