diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-04-14 13:48:30 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-04-14 13:48:30 (EDT) |
commit | b208ec1fc1fb4452647560346cc1ea71179c698a (patch) | |
tree | b869410f9033f5826b80baa2a3cebe22b5e0e7d4 /src | |
parent | 68d6eeb8e72ee04f98dba24aa778761f869b9432 (diff) |
main(): Return on invalid options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.sh | 16 |
1 files changed, 12 insertions, 4 deletions
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:-.}" |