bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why does time (cmd) 2> file redirect time's output?


From: Isabella Parakiss
Subject: Re: why does time (cmd) 2> file redirect time's output?
Date: Tue, 8 Mar 2016 12:04:45 +0100
User-agent: Mutt/1.5.24 (2015-08-30)

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    chet@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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]