diff options
author | Helmut Grohne <helmut@subdivi.de> | 2023-01-08 20:56:46 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2023-01-08 20:56:46 +0100 |
commit | fa7ce55eb2d61dfd3a6e8056f6217a5888c2798b (patch) | |
tree | 8117673c80b2dd78879cf199458c8841a20ef8c8 | |
parent | 96349ad9ccb4a9c58c4cb32fefcf89d1a76a224f (diff) | |
download | debvm-fa7ce55eb2d61dfd3a6e8056f6217a5888c2798b.tar.gz |
debvm-waitssh: standardize option parser
An option --foo is handled by opt_foo.
-rwxr-xr-x | debvm-waitssh | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/debvm-waitssh b/debvm-waitssh index 32db862..246db17 100755 --- a/debvm-waitssh +++ b/debvm-waitssh @@ -81,22 +81,25 @@ usage_error() { usage } +opt_help() { + # shellcheck disable=SC2317 # not dead, called as "opt_$OPTARG" + usage +} +opt_quiet() { + VERBOSITY=0 +} opt_timeout() { TOTALTIMEOUT=$1 } -opt_verbosity() { - VERBOSITY=$1 -} - while getopts :qt:-: OPTCHAR; do case "$OPTCHAR" in - q) opt_verbosity 0;; + q) opt_quiet ;; t) opt_timeout "$OPTARG" ;; -) case "$OPTARG" in - help) - usage + help|quiet) + "opt_$OPTARG" ;; timeout) test "$OPTIND" -gt "$#" && usage_error "missing argument for --$OPTARG" @@ -106,9 +109,6 @@ while getopts :qt:-: OPTCHAR; do timeout=) "opt_${OPTARG%%=*}" "${OPTARG#*=}" ;; - quiet) - opt_verbosity 0 - ;; *) usage_error "unrecognized option --$OPTARG" ;; |