aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/pvscheck.sh19
1 files changed, 16 insertions, 3 deletions
diff --git a/scripts/pvscheck.sh b/scripts/pvscheck.sh
index 79ed08f458..949021a174 100755
--- a/scripts/pvscheck.sh
+++ b/scripts/pvscheck.sh
@@ -50,7 +50,17 @@ help() {
}
getopts_error() {
- printf '%s\n' "$1" >&2
+ local msg="$1" ; shift
+ local do_help=
+ if test "$msg" = "--help" ; then
+ msg="$1" ; shift
+ do_help=1
+ fi
+ printf '%s\n' "$msg" >&2
+ if test -n "$do_help" ; then
+ printf '\n' >&2
+ help >&2
+ fi
echo 'return 1'
return 1
}
@@ -146,8 +156,8 @@ getopts_long() {
if test -n "$opt_base" ; then
eval "local occurred_$opt_base=1"
- eval "local act_1=\"\$act_1_$opt_base\""
- eval "local varname=\"\$varname_$opt_base\""
+ eval "local act_1=\"\${act_1_$opt_base:-}\""
+ eval "local varname=\"\${varname_$opt_base:-}\""
local need_val=
local func=
case "$act_1" in
@@ -170,6 +180,9 @@ getopts_long() {
eval "varname=\"\${act_3_${opt_base}:-$varname}\""
need_val=1
;;
+ ("")
+ getopts_error --help "Wrong argument: $argument"
+ ;;
esac
if test -n "$need_val" ; then
local val=