[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can't wait for process substitution redirected for a subshell
From: |
Chet Ramey |
Subject: |
Re: Can't wait for process substitution redirected for a subshell |
Date: |
Wed, 25 Apr 2018 09:04:26 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
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 chet@case.edu http://tiswww.cwru.edu/~chet/