Process Substitution subshell inherits the desire to print its times if
From:
Basin Ilya
Subject:
Process Substitution subshell inherits the desire to print its times if it contains explicit exit
Date:
Wed, 4 Apr 2018 11:21:56 +0300
User-agent:
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0
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.
#!/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 $!
Output:
real 0m0.252s
user 0m0.001s
sys 0m0.001s
real 0m0.259s
user 0m0.003s
sys 0m0.002s
Bash version 4.4.19, Arch64.
Earlier bash versions just print: wait: pid 28717 is not a child of this shell