mirror of https://github.com/spf13/cobra.git
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
|
@ -175,6 +175,8 @@ __handle_flag()
|
|||
fi
|
||||
|
||||
# keep flag value with flagname as flaghash
|
||||
# flaghash variable is an associative array which is only supported in bash > 3.
|
||||
if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
|
||||
if [ -n "${flagvalue}" ] ; then
|
||||
flaghash[${flagname}]=${flagvalue}
|
||||
elif [ -n "${words[ $((c+1)) ]}" ] ; then
|
||||
|
@ -182,6 +184,7 @@ __handle_flag()
|
|||
else
|
||||
flaghash[${flagname}]="true" # pad "true" for bool flag
|
||||
fi
|
||||
fi
|
||||
|
||||
# skip the argument to a two word flag
|
||||
if __contains_word "${words[c]}" "${two_word_flags[@]}"; then
|
||||
|
|
Loading…
Reference in New Issue