mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-02-07 20:59:12 +01:00
lib: Fix 'getargs' setting an empty string when no args are left
This commit is contained in:
parent
e4e916c63b
commit
650845dee4
@ -61,7 +61,11 @@ getargs() {
|
||||
eval "$2=(\"\${$2[@]}\" $(printf '%q ' "${_ARGV[@]:$_ARGV_INDEX}"))"
|
||||
fi
|
||||
else
|
||||
eval "$1=($(printf '%q ' "${_ARGV[@]:$_ARGV_INDEX}"))"
|
||||
if [[ "${_ARGV_INDEX}" -ne "$((_ARGV_LAST+1))" ]]; then
|
||||
eval "$1=($(printf '%q ' "${_ARGV[@]:$_ARGV_INDEX}"))"
|
||||
else
|
||||
eval "$1=()"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -413,7 +413,13 @@ test:fn_getargs() {
|
||||
|
||||
# Ensure getargs doesn't remove remaining arguments.
|
||||
shiftopt
|
||||
assert_opt_name "three"
|
||||
assert_opt_name "three"
|
||||
|
||||
# Ensure it doesn't set an empty string.
|
||||
args=(one two)
|
||||
setargs
|
||||
getargs args
|
||||
assert_equal 0 "${#args[@]}"
|
||||
}
|
||||
|
||||
test:fn_getargs_append() {
|
||||
|
Loading…
Reference in New Issue
Block a user