On 4/4/18 4:21 AM, Basin Ilya wrote:
> Hi.
> In an attempt to capture the output of 'time' I used the process substitution 
> and noticed that the subshell also prints its times. Actually I this happens 
> when I redirect any fd, not just stderr.

It's an interaction between command timing and the `exit' builtin wanting
to make sure it does things like run any exit trap. The file descriptor
manipulation doesn't matter; it's the process substitution subshell
creation that does it. A command like `cat <( echo procsub ; exit 0)'
would work just as well. I'll take a look at the best way to fix it.

>     #!/bin/bash
>     time {
>       sleep 0.25
>       exec 6> >(
>         sed 's/^/captured: /'
>         exit 0
>       )
>     }
>     # close write side of the pipe and wait for reader
>     exec 6>&-
>     wait $!

> Earlier bash versions just print: wait: pid 28717 is not a child of this shell

Bash-4.4 allows wait to reap the last process substitution created, since
it sets $!.

``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