summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/getopt.sh13
1 files changed, 10 insertions, 3 deletions
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}\""