Path: csiph.com!feeder.erje.net!2.us.feeder.erje.net!weretis.net!feeder6.news.weretis.net!news.glorb.com!usenet.stanford.edu!not-for-mail From: Greg Wooledge Newsgroups: gnu.bash.bug Subject: Re: ${1+"$@"} does not generate multiple words if IFS is empty Date: Wed, 30 Dec 2015 08:00:15 -0500 Lines: 24 Approved: bug-bash@gnu.org Message-ID: References: <56835243.0Dp3As7Vk0rP8qDy%martijn@inlv.org> <87io3gtiku.fsf@igel.home> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: usenet.stanford.edu 1451480453 31289 208.118.235.17 (30 Dec 2015 13:00:53 GMT) X-Complaints-To: action@cs.stanford.edu Cc: martijn@inlv.org, bug-bash@gnu.org To: Andreas Schwab Envelope-to: bug-bash@gnu.org Content-Disposition: inline In-Reply-To: <87io3gtiku.fsf@igel.home> User-Agent: Mutt/1.4.2.3i X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 139.137.100.1 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:12134 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 [...]