[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ${1+"$@"} does not generate multiple words if IFS is empty
From: |
Greg Wooledge |
Subject: |
Re: ${1+"$@"} does not generate multiple words if IFS is empty |
Date: |
Wed, 30 Dec 2015 08:00:15 -0500 |
User-agent: |
Mutt/1.4.2.3i |
On Wed, Dec 30, 2015 at 10:02:41AM +0100, Andreas Schwab wrote:
> martijn@inlv.org writes:
>
> > The substitution ${1+"$@"} should resolve to "$@" if there is at
> > least one parameter -- i.e. one word per parameter. This works fine
> > if IFS contains any character or is unset. If IFS is empty, it
> > instead resolves to the equivalent of "$*", i.e. a single word
> > concatenating all the parameters without a separator. IFS should
> > not influence the behaviour of "$@" under any circumstances.
>
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_05
>
> "If the value of IFS is null, no field splitting shall be performed."
By itself that doesn't explain it. But if you scroll up to
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_05_02
it says:
@
Expands to the positional parameters, starting from one. When the
expansion occurs within double-quotes, and where field splitting (see
Field Splitting) is performed, each positional parameter shall expand
as a separate field [...]