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:
Kazuki Suda 2018-02-05 01:42:17 +09:00 committed by Eric Paris
parent 3a7eb146ba
commit 9979838ec4
1 changed files with 9 additions and 6 deletions

View File

@ -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