[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
"$@" expansion when it is consists of only null strings
From: |
Grisha Levit |
Subject: |
"$@" expansion when it is consists of only null strings |
Date: |
Sun, 24 Feb 2019 18:37:33 -0500 |
There are some what seem to be regressions (?) in bash-4.4 and
bash-5.0 regarding the handling of "$@" expansion when it consists
entirely of null strings.
The relevant commits are bash-20160722 [1], bash-20170331 [2],
bash-20190220 [3].
Using:
$ n() { echo $#; }
Since bash-20160722:
$ set -- ''
$ n "$@"''
0
$ set -- '' ''
n ''"$@"
1
n "$@"''
1
n ''"$@"''
0
(and, since bash-20190220, also in the ${x+} PE form)
Since bash-20170331:
$ set -- ''
$ n ${_+''"$@"''}
0
$ n ${_+"$@" "$@"}
1
On a related note, with $#=0, bash-20190220 fixed the expansion of
${_"$@"''} and ${''"$@"} to produce a single field but not so with:
$ set --
$ n ${_+''"$@"''}
0
And these have always been the case, but I'm not sure if it should be so?
$ set --
$ n "${_+"$@"}"
1
$ n "${_+$@}"
1
[1]:
https://git.savannah.gnu.org/cgit/bash.git/commit/?h=devel&id=13eae87b0c5dbc31a7d352ce17c6817bb79b9226
[2]:
https://git.savannah.gnu.org/cgit/bash.git/commit/?h=devel&id=7c4ef411b5f1a458c2908efe503e075e5a682040
[3]:
https://git.savannah.gnu.org/cgit/bash.git/commit/?h=devel&id=9e48f856544da2d2cc95600f487e5b5bcefa0d85
- "$@" expansion when it is consists of only null strings,
Grisha Levit <=