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: Chet Ramey
Subject: Re: why does time (cmd) 2> file redirect time's output?
Date: Fri, 29 Jan 2016 12:08:38 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.5.1

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    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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