Sorry that wasn’t very clear. I only included that case to demonstrate that
seemingly contradictory things are happening:

   - "${_+$@}" expands each positional parameter to a separate word,
   following the usual "$@" behavior
   - The usual "$@" behavior is to expand to 0 words if there are no
   positional params but in this case "${_+$@}" expands to an empty string
   instead
   - If we interpret "${_+$@}" as being equivalent to "${_+}" when there
   are no params, then the two cases above seem reconcilable, but still
   "${_+${_+$@}}" expanding to nothing does not make sense.

I suspect the below is not really the desired behavior?

fun() { echo $#; }

fun "$@"0
fun "${_+$@}"1
fun "${_+${_+$@}}"0
fun "${_+${_+${_+$@}}}"1
fun "${_+${_+${_+${_+$@}}}}"0
fun "${_+${_+${_+${_+${_+$@}}}}}"1

FWIW bash 4.1 and below treat all but the first case as one word.

Reply via email to