mirror of
https://github.com/eth-p/bat-extras.git
synced 2024-10-05 01:11:57 +02: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}"))"
|
eval "$2=(\"\${$2[@]}\" $(printf '%q ' "${_ARGV[@]:$_ARGV_INDEX}"))"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
if [[ "${_ARGV_INDEX}" -ne "$((_ARGV_LAST+1))" ]]; then
|
||||||
eval "$1=($(printf '%q ' "${_ARGV[@]:$_ARGV_INDEX}"))"
|
eval "$1=($(printf '%q ' "${_ARGV[@]:$_ARGV_INDEX}"))"
|
||||||
|
else
|
||||||
|
eval "$1=()"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,6 +414,12 @@ test:fn_getargs() {
|
|||||||
# Ensure getargs doesn't remove remaining arguments.
|
# Ensure getargs doesn't remove remaining arguments.
|
||||||
shiftopt
|
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() {
|
test:fn_getargs_append() {
|
||||||
|
Loading…
Reference in New Issue
Block a user