From 3a6e67783cfa816c37e02b5eea8ef7607e680b6a Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Sun, 8 Jan 2023 10:33:24 +0100 Subject: debvm-waitssh: add --quiet option --- debvm-waitssh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/debvm-waitssh b/debvm-waitssh index 4d69657..857a958 100755 --- a/debvm-waitssh +++ b/debvm-waitssh @@ -9,7 +9,7 @@ debvm-waitssh - Wait for a ssh server to be reachable =head1 SYNOPSIS -B [B<-t> I] [I:]I +B [B<-q>] [B<-t> I] [I:]I =head1 DESCRIPTION @@ -25,6 +25,10 @@ If no hostname is given, B<127.0.0.1> is assumed. Set the maximum duration for waiting in seconds. Defaults to one minute. +=item B<-q>, B<--quiet> + +Be quiet. Output nothing on standard error, not even error messages. + =back =head1 EXIT VALUES @@ -57,6 +61,7 @@ set -u TOTALTIMEOUT=60 SCANTIMEOUT=10 SCANDELAY=1 +VERBOSITY=1 nth_arg() { shift "$1" @@ -68,7 +73,7 @@ die() { exit 2 } usage() { - die "usage: $0 [-t ] [:]" + die "usage: $0 [-q] [-t ] [:]" } usage_error() { echo "error: $*" >&2 @@ -79,8 +84,13 @@ opt_timeout() { TOTALTIMEOUT=$1 } -while getopts :t:-: OPTCHAR; do +opt_verbosity() { + VERBOSITY=$1 +} + +while getopts :qt:-: OPTCHAR; do case "$OPTCHAR" in + q) opt_verbosity 0;; t) opt_timeout "$OPTARG" ;; -) case "$OPTARG" in @@ -95,6 +105,9 @@ while getopts :t:-: OPTCHAR; do timeout=) "opt_${OPTARG%%=*}" "${OPTARG#*=}" ;; + quiet) + opt_verbosity 0 + ;; *) usage_error "unrecognized option --$OPTARG" ;; -- cgit v1.2.3