From b208ec1fc1fb4452647560346cc1ea71179c698a Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sun, 14 Apr 2019 13:48:30 -0400 Subject: main(): Return on invalid options --- (limited to 'src') diff --git a/src/main.sh b/src/main.sh index f50cad4..549e45e 100644 --- a/src/main.sh +++ b/src/main.sh @@ -47,9 +47,14 @@ _get_options() unset OPTARG while getopts "${OPTSTRING}" opt; do - if [ "x${opt}" != 'x?' ]; then - eval "opt_${opt}=\"\${OPTARG:-true}\"" - fi + case "${opt}" in + '?') + return 1 + ;; + *) + eval "opt_${opt}=\"\${OPTARG:-true}\"" + ;; + esac unset OPTARG done @@ -70,7 +75,10 @@ main() load_locale || return 1 - _get_options "${@}" + if ! _get_options "${@}"; then + cmd_help_main 1>&2 + return 1 + fi shift $((${OPTIND} - 1)) base_dir="${opt_b:-.}" -- cgit v0.9.1