mirror of
https://github.com/spf13/cobra
synced 2024-11-24 14:47:12 +00:00
Fix attemptd assignment to non-variable in bash 3 (#628)
* Fix attemptd assignment to non-variable in bash 3 flaghash variable is an associative array which is only supported in bash > 3. * Use -gt instead of >
This commit is contained in:
parent
3a7eb146ba
commit
9979838ec4
1 changed files with 9 additions and 6 deletions
|
@ -175,12 +175,15 @@ __handle_flag()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# keep flag value with flagname as flaghash
|
# keep flag value with flagname as flaghash
|
||||||
if [ -n "${flagvalue}" ] ; then
|
# flaghash variable is an associative array which is only supported in bash > 3.
|
||||||
flaghash[${flagname}]=${flagvalue}
|
if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
|
||||||
elif [ -n "${words[ $((c+1)) ]}" ] ; then
|
if [ -n "${flagvalue}" ] ; then
|
||||||
flaghash[${flagname}]=${words[ $((c+1)) ]}
|
flaghash[${flagname}]=${flagvalue}
|
||||||
else
|
elif [ -n "${words[ $((c+1)) ]}" ] ; then
|
||||||
flaghash[${flagname}]="true" # pad "true" for bool flag
|
flaghash[${flagname}]=${words[ $((c+1)) ]}
|
||||||
|
else
|
||||||
|
flaghash[${flagname}]="true" # pad "true" for bool flag
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# skip the argument to a two word flag
|
# skip the argument to a two word flag
|
||||||
|
|
Loading…
Reference in a new issue