On both Bash 4.4.12(1)-release and 5.0.0(1)-alpha, a subarray slice like
${a[@]:0} expands to just one word if unquoted (and if IFS doesn't
contain a space):
$ a=(aa bb); IFS=x; printf ":%s:\n" ${a[@]:0}
:aa bb:
I expected it would expand to separate words, as it does without the
slice, and just like $@ does, sliced or not:
$ a=(aa bb); IFS=x; printf ":%s:\n" ${a[@]}
:aa:
:bb:
$ set -- aa bb; IFS=x; printf ":%s:\n" $@
:aa:
:bb:
$ set -- aa bb; IFS=x; printf ":%s:\n" ${@:1}
:aa:
:bb:
It's as if it first joins the picked elements with spaces, and then
splits using IFS, instead of producing multiple words and word-splitting
them individually.
The same thing happens with ${a[*]:0} (but not with ${*:1}):
the array elements get joined with spaces to a single word. If IFS is
empty, unset, or contains a space the result is multiple words as
expected with both [@] and [*].
An expansion like that should in most cases be quoted,
but the current behaviour still seems a bit inconsistent.
--
Ilkka Virta / itvi...@iki.fi