bug-bash
[Top][All Lists]
Advanced

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

Re: excess braces ignored: bug or feature ?


From: Chet Ramey
Subject: Re: excess braces ignored: bug or feature ?
Date: Tue, 21 Feb 2012 14:50:00 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0

On 2/20/12 2:32 AM, Dan Douglas wrote:

>>> That one really is ignored. No variable named xxx... is actually set.
>>
>> I assume you mean the first one.  It doesn't matter whether or not the
>> variable is set as a side effect of the redirection -- it's in a
>> subshell and disappears.
>>
>> Chet
> 
> Oh so a subshell is created after all, and that really is a command 
> substitution + redirect! I just chalked it up to Bash recycling the way 
> redirects were parsed.

Bash always forks for command substitution.  It defers parsing the command
between the parens until it's needed, and so doesn't notice that it's only
a redirection until it has already forked.  It is able to skip the exec and
dump the file out directly.

> 
> I think I ran across that quirk in trying to determine whether $(<file) was a 
> special command substitution or it's own kind of expansion but couldn't think 
> of a way to test it. 

It's a special command substitution (there are others).  David has gone to
great lengths to  avoid forking in ksh93 wherever possible; I assume this
is one of those  places where he's managed to do so.

Chet

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



reply via email to

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