From 2cd968e982bb9942e6d044270a42de88d8d01b67 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 26 May 2015 18:07:14 -0400 Subject: Merge branch 'feature/installer-integration' --- (limited to 'lib/getopt.sh') 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 -- cgit v0.9.1