On 4/24/18 4:46 PM, Geir Hauge wrote:
> Waiting on a process substitution that is used in redirection for a
> command grouping works, but not when using a subshell in place of that
> command grouping:
> 
>     $ TIMEFORMAT=%R
>     $ time bash -c '{ :; } 2> >(sleep 2); wait "$!"'
>     2.013
>     $ time bash -c '(:) 2> >(sleep 2); wait "$!"'
>     bash: line 0: wait: `': not a pid or valid job spec
>     0.008
> 
> I'd expect those two cases to behave the same way.
> 
> It looks like the redirection is done after the subshell is forked, so
> adding the wait inside the subshell actually works:

Yes, expansion and redirections are performed in a subshell when the shell
executes a subshell command. Bash has always behaved like this, and I don't
foresee changing it.

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

Reply via email to