On Thu, Jun 24, 2021 at 5:20 PM Chet Ramey <chet.ra...@case.edu> wrote:
> On 6/24/21 4:09 AM, Ilkka Virta wrote: > > > But 3.4 Shell Parameters is a bit confusing: "Word splitting is not > > performed, with the exception of "$@" as explained below." > > This means that "$@" expands to multiple words, even though double quotes > would usually inhibit that. > Like Nora already mentioned, that quote is from the paragraph about scalar variable assignment, where it doesn't appear to produce more than one word, but instead behaves exactly as described in Special Parameters for the case where word- splitting does _not_ happen. As far as I can tell, the behaviour is the same as when $@ is used in the tested word or one of the patterns in a 'case' statement or inside [[. The description for 'case' omits any mention of word splitting, and the description for [[ explicitly mentions it's not done, but neither/none of those mention any exceptions. As an aside, the description of $* could perhaps also be changed to also mention those non-word-splitting contexts, and not only quoted and unquoted contexts, since in all the non-splitting cases mentioned above, $* seems to expand to just a single word even if it's not quoted. (Using the first character of IFS as joiner, of course).