bug-bash
[Top][All Lists]
Advanced

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

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


From: Kevin Brodsky
Subject: Re: Unexpected word splitting on $* when IFS is unset
Date: Wed, 21 Jun 2017 00:07:14 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0

On 20/06/2017 06:33, Eduardo A. Bustamante López wrote:
> On Tue, Jun 20, 2017 at 01:13:07AM +0100, Kevin Brodsky wrote:
> [...]
>> When IFS is unset, unquoted $* undergoes word splitting as if IFS=' ',
>> and not the expected IFS=$' \t\n'. All the other unquoted mass
>> This is a regression that appeared in 4.3 and is still present on devel
> [...]
>
> AFAICT, the following patch fixes this.
>
> diff --git a/subst.c b/subst.c
> index 3093309f..bf73a35f 100644
> --- a/subst.c
> +++ b/subst.c
> @@ -10158,7 +10158,7 @@ finished_with_string:
>        or we expanded "$@" with IFS null and we need to split the positional
>        parameters into separate words. */
>        if (split_on_spaces)
> -     list = list_string (istring, " ", 1);   /* XXX quoted == 1? */
> +     list = list_string (istring, " \t\n", 1);       /* XXX quoted == 1? */
>        /* If we have $@ (has_dollar_at != 0) and we are in a context where we
>        don't want to split the result (W_NOSPLIT2), and we are not quoted,
>        we have already separated the arguments with the first character of
>
> The above code (`list_string' function call when split_on_spaces != 0)
> seems to be executed when IFS is either unset or the empty string. The
> comment above that block of code mentions that in either case, the
> result should be "split on spaces", although it has a narrow definition
> of space.
>

The comments about "IFS either unset or null" confuse me, because word
splitting should behave very differently when IFS is null (there is no
word splitting at all, whereas unset IFS is equivalent to IFS=$' \t\n').
My tests show that the behaviour is as expected when IFS is null, so I'm
wondering if the comments match the actual behaviour.

Kevin



reply via email to

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