summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick 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)
commitb208ec1fc1fb4452647560346cc1ea71179c698a (patch)
treeb869410f9033f5826b80baa2a3cebe22b5e0e7d4
parent68d6eeb8e72ee04f98dba24aa778761f869b9432 (diff)
main(): Return on invalid options
-rw-r--r--src/main.sh16
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:-.}"