From ad0571b72af86980a42cafdc005f064243b2fe1e Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Wed, 23 Oct 2013 21:22:26 -0400 Subject: get_options(): Determine optstring and prefix. --- diff --git a/lib/getopt.sh b/lib/getopt.sh index 9292af2..537892b 100644 --- a/lib/getopt.sh +++ b/lib/getopt.sh @@ -22,11 +22,18 @@ _GETOPT_SM=1 get_options() { - local optstring="${1}" - local prefix="${2}" - shift 2 + local optstring= + local prefix= local opt= + if [ "x${running_cmd}" = 'x' ]; then + optstring="${OPTSTRING}" + prefix='opt_' + else + eval "optstring=\"\${cmd_${running_cmd}_optstring}\"" + prefix="cmd_${running_cmd}_opt_" + fi + unset OPTARG while getopts "${optstring}" opt; do eval "${prefix}${opt}=\"\${OPTARG:-true}\"" -- cgit v0.9.1