[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unexpected word splitting on $* when IFS is unset

From: Chet Ramey
Subject: Re: Unexpected word splitting on $* when IFS is unset
Date: Wed, 21 Jun 2017 15:29:59 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.2.0

On 6/21/17 2:43 PM, Kevin Brodsky wrote:

> That is also my reading of POSIX (and that's more or less what Bash's
> manpage says as well), but it doesn't seem to be the case (even in <=4.2):

That's a relatively new requirement.  The portion of the relevant sentence
that reads "initially producing one field for each positional parameter
that is set" is new as of issue 7 TC2. Without that, the splitting rules
for $* were effectively identical whether it was quoted or not quoted --
they were separated using the first character of $IFS. In a context where
they were not quoted and word splitting took place, this had the side
effect of splitting them in an unquoted context. When IFS is null, that
resulted in no splitting.

There were long discussions on the Posix list about this starting in late
2014, resulting in Posix interp 888.


There are still some cases where I haven't completely made bash conform to
the new spec.

>   $ set -- 'a b'
>   $ IFS=''
>   $ nb_args $*
>   1
>   $ nb_args $@
>   1

This is a different situation: when IFS is null, there is no splitting. So
N fields are produced, one for each of N positional parameters, but they
are not split any further.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]