On Wednesday, May 23, 2012 09:47:33 PM gregrwm wrote: > expansion anomaly with quoted and concatenated positional parameters
Also reproducible in 4.2.28(1)-release This occurs when any expansion is adjacent to or contained within a word that is adjacent to an expansion of the from "$@" or "${a[@]}", and within the same double-quotes. Bash mistakenly treats "${@}${x}" and "${@}""$x" differently. > echo '${@:2}c$1 c2 c3 #works as long as quoting omitted' Because you're applying word-splitting to the result. You'll see that there is only one word if IFS is set to null. It's impossible to test whether the unquoted case is correct. The manpage says that only a quoted "$@" is split into words for reasons other than word-splitting. Bash, mksh, and dash all disagree about the unquoted cases, while Bash is the only shell to take issue with the adjacent expansion in all cases. ~ $ for sh in {{,m}k,{d,b}a,z}sh; do printf '%s\n' "${sh}:" "$("$sh" -c "$(</dev/stdin)" -- {1..5})"; echo; done <<"EOF" args() { printf '<%s> ' "$@"; echo; } args "${@}${1}" args "${@}foo" args ${@}${1} args ${@}foo IFS= args ${@}${1} args ${@}foo EOF ksh: <1> <2> <3> <4> <51> <1> <2> <3> <4> <5foo> <1> <2> <3> <4> <51> <1> <2> <3> <4> <5foo> <1> <2> <3> <4> <51> <1> <2> <3> <4> <5foo> mksh: <1> <2> <3> <4> <51> <1> <2> <3> <4> <5foo> <1> <2> <3> <4> <51> <1> <2> <3> <4> <5foo> <1 2 3 4 51> <1 2 3 4 5foo> dash: <1> <2> <3> <4> <51> <1> <2> <3> <4> <5foo> <1> <2> <3> <4> <51> <1> <2> <3> <4> <5foo> <123451> <12345foo> bash: <1 2 3 4 51> <1> <2> <3> <4> <5foo> <1> <2> <3> <4> <51> <1> <2> <3> <4> <5foo> <1 2 3 4 51> <1> <2> <3> <4> <5foo> zsh: <1> <2> <3> <4> <51> <1> <2> <3> <4> <5foo> <1> <2> <3> <4> <51> <1> <2> <3> <4> <5foo> <1> <2> <3> <4> <51> <1> <2> <3> <4> <5foo> -- Dan Douglas
signature.asc
Description: This is a digitally signed message part.