summaryrefslogtreecommitdiffstats
path: root/lib/getopt.sh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/getopt.sh')
-rw-r--r--lib/getopt.sh18
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