On Fri, Jan 29, 2016 at 12:08:38PM -0500, Chet Ramey wrote: > On 1/27/16 5:59 AM, Stephane Chazelas wrote: > > Hello, > > > > (tested with bash-4.3 and bash-2.05b) > > > > "time" is meant to time a pipeline. That generally includes > > redirections of the last command in the pipeline, but in the > > case of a subshell alone, the redirection is not timed(*) and > > seems to affect the output of "time" itself. > > It's the way the bash implementation was from the start. If the command > to be timed is run in a subshell and not part of a pipeline, the shell > forks early and runs the command in a subshell. In this case, that > subshell performs redirections before doing much of anything else. > > As you note below, some people have relied on it. > > Chet > -- > ``The lyf so short, the craft so long to lerne.'' - Chaucer > ``Ars longa, vita brevis'' - Hippocrates > Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/ >
This seems to be a related problem: $ time (exec true) # doesn't print anything $ time ( (exec true) ) # doesn't print anything $ time ( ( (exec true) ) ) # doesn't print anything $ time { (exec true); } real: 0m0.001s, user: 0m0.000s, sys: 0m0.000s --- xoxo iza