diff options
author | P. J. McDermott <pj@pehjota.net> | 2015-05-26 18:07:14 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2015-05-26 18:07:14 (EDT) |
commit | 2cd968e982bb9942e6d044270a42de88d8d01b67 (patch) | |
tree | 4751e5a9802ce2d0b319e5a988ce723db8611660 /lib/getopt.sh | |
parent | 78a64f4f12a28be389fdc935cdf7dcfddf386c35 (diff) | |
parent | 27abaab4e6861d60f1316349395eeff57b65c964 (diff) |
Merge branch 'feature/installer-integration'
Diffstat (limited to 'lib/getopt.sh')
-rw-r--r-- | lib/getopt.sh | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/getopt.sh b/lib/getopt.sh index 32fb57d..b8d90fb 100644 --- a/lib/getopt.sh +++ b/lib/getopt.sh @@ -27,21 +27,27 @@ get_options() local prefix= local opt= - if [ "x${running_cmd}" = 'x' ]; then + if [ "x${running_cmd_clean}" = 'x' ]; then optstring="${OPTSTRING}" prefix='opt_' else - eval "optstring=\"\${cmd_${running_cmd}_optstring}\"" - prefix="cmd_${running_cmd}_opt_" + eval "optstring=\"\${cmd_${running_cmd_clean}_optstring}\"" + prefix="cmd_${running_cmd_clean}_opt_" fi 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 |