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 [email protected] http://cnswww.cns.cwru.edu/~chet/