[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Word splitting for $@ in variable assignment
From: |
Nora Platiel |
Subject: |
Re: Word splitting for $@ in variable assignment |
Date: |
Fri, 25 Jun 2021 01:47:01 +0200 |
I was also confused by the same statement.
On 2021-06-24 10:20 Chet Ramey 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.
To me, "$@" expanding to multiple words would mean that:
$ var="$@" foo
for $# > 0, behaves the same as:
$ var="$1" "${@:2}" foo
which is obviously not the case.
I don't know how this is implemented, maybe they are actually split into
multiple words, and such words somehow remain in the context of the assignment
and are rejoined later.
But the user doesn't see that. The user just see that on the RHS of an
assignment, "$@" produces a single string (by joining arguments), and such
string is not split in any way.
I second the proposal of removing the part: `with the exception of "$@" as
explained below', because I think it serves no useful purpose and adds
confusion.
Regards,
NP