[prev in list] [next in list] [prev in thread] [next in thread]
List: bash-bug
Subject: Re: Process Substitution subshell inherits the desire to print its times if it contains explicit exi
From: Chet Ramey <chet.ramey () case ! edu>
Date: 2018-04-04 18:36:02
Message-ID: ef698caa-0717-25bf-be1a-cfa0b8799e19 () case ! edu
[Download RAW message or body]
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 $!.
Chet
--
``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/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic