[Toybox] Would someone please explain what bash is doing here?

scsijon scsijon at lamiaworks.com.au
Thu May 21 22:42:51 PDT 2020



On 22/5/20 12:49 pm, toybox-request at lists.landley.net wrote:
> 
> Message: 2
> Date: Thu, 21 May 2020 17:50:49 -0500
> From: Rob Landley <rob at landley.net>
> To: chet.ramey at case.edu, enh <enh at google.com>
> Cc: toybox <toybox at lists.landley.net>
> Subject: Re: [Toybox] Would someone please explain what bash is doing
> 	here?
> Message-ID: <713fa4a5-28ad-6664-7696-e1ddd7878874 at landley.net>
> Content-Type: text/plain; charset=utf-8
> 
> On 5/20/20 8:39 AM, Chet Ramey wrote:
>> On 5/19/20 4:03 PM, Rob Landley wrote:
>>> On 5/18/20 10:41 AM, Chet Ramey wrote:
>>>> On 5/17/20 7:11 AM, Rob Landley wrote:
>>>>> I had a reply window open to this when my laptop battery died, and thunderbird
>>>>> doesn't store unfinished messages like kmail and vi and chrome...
>>>>>
>>>>> Anyway, I was reminded of this thread by:
>>>>>
>>>>>    $ IFS=x; ABC=cxd; for i in +($ABC); do echo =$i=; done
>>>>>    =+(c=
>>>>>    =d)=
>>>>>    $ bash -c 'IFS=x; ABC=cxd; for i in +($ABC); do echo =$i=; done'
>>>>>    bash: -c: line 0: syntax error near unexpected token `('
>>>>>    bash: -c: line 0: `IFS=x; ABC=cxd; for i in +($ABC); do echo =$i=; done'
>>>>>    $ readlink -f /proc/$$/exe
>>>>>    /bin/bash
>>>>
>>>> Yes, you need extglob to get a word like +(xyz) to parse unquoted. Since
>>>> the word list following `in' is subject to pathname expansion, it's valid
>>>> in that context.
>>>
>>> But the same command line in the current shell and in bash -c are parsing
>>> different despite presumably reading the same .bashrc and friends?
>>
>> My guess is that the interactive shell has extglob enabled somehow, whether
>> it was in .bashrc or interactively after it was started. The -c command
>> shell doesn't read startup files, so that doesn't matter.
> 
> Mine too, but grep isn't finding extglob under /etc or ~/.*

? from inside /etc/bash.bashrc

/cut

regards
scsijon



More information about the Toybox mailing list