diff options
-rw-r--r-- | lib/getopt.sh | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/getopt.sh b/lib/getopt.sh index 048e02b..b8d90fb 100644 --- a/lib/getopt.sh +++ b/lib/getopt.sh @@ -37,11 +37,17 @@ get_options() unset OPTARG while getopts "${optstring}" opt; do - if [ "x${opt}" != 'x?' ]; then - eval "${prefix}${opt}=\"\${OPTARG:-true}\"" - else + if [ "x${opt}" = 'x?' ]; then return 1 fi + case "${optstring}" in + *"${opt}:"*) + eval "${prefix}${opt}=\"\${OPTARG}\"" + ;; + *) + eval "${prefix}${opt}=true" + ;; + esac unset OPTARG done |