[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Quilt-dev] [patch 3/8] tac is not portable
From: |
Dave Dodge |
Subject: |
Re: [Quilt-dev] [patch 3/8] tac is not portable |
Date: |
Fri, 16 Sep 2005 01:22:26 -0400 |
User-agent: |
Mutt/1.4.2i |
On Thu, Sep 15, 2005 at 09:52:14PM +0200, Jean Delvare wrote:
> $ time true | sleep 1
>
> real 0m1.012s
> user 0m0.004s
> sys 0m0.004s
>
> $ (time true) | sleep 1
>
> real 0m0.007s
> user 0m0.004s
> sys 0m0.004s
>
> I guess the left-hand side of the pipe needs to wait for the right-hand
> side of the pipe to exit before it can exit itself, in order to get the
> return code or something alike.
Bear in mind that "time" is a reserved word in bash and is considered
part of the basic pipeline grammar. It's applied to its entire
pipeline, not just the first command. From the bash "Pipelines" info
node:
The format for a pipeline is
[`time' [`-p']] [`!'] COMMAND1 [`|' COMMAND2 ...]
You can see the difference if you force the shell to use the non-builtin
time program instead:
$ /usr/bin/time true | sleep 1
0.00user 0.00system 0:00.01elapsed 0%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (102major+9minor)pagefaults 0swaps
$ (/usr/bin/time true) | sleep 1
0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (102major+9minor)pagefaults 0swaps
And the word "time" behaves as a normal command if you place it in the
middle of the pipeline:
$ true | time true | sleep 1
0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (102major+9minor)pagefaults 0swaps
> $ time (true | sleep 1)
>
> returns only after the 1 second sleep, but doesn't print anything. I
> have no idea why.
This happens for anything using parentheses grouping:
$ time (true)
Perhaps it's a bug in the bash parser. I notice that it does work as
expected for brace grouping:
$ time { true | sleep 1; }
real 0m0.000s
user 0m0.000s
sys 0m0.000s
Also of note:
$ time true && sleep 1
real 0m0.000s
user 0m0.000s
sys 0m0.000s
-Dave Dodge
- Re: [Quilt-dev] [patch 3/8] tac is not portable, (continued)
- Re: [Quilt-dev] [patch 3/8] tac is not portable, Andreas Gruenbacher, 2005/09/15
- Re: [Quilt-dev] [patch 3/8] tac is not portable, Josh Boyer, 2005/09/15
- Re: [Quilt-dev] [patch 3/8] tac is not portable, Jean Delvare, 2005/09/15
- Re: [Quilt-dev] [patch 3/8] tac is not portable, Josh Boyer, 2005/09/15
- Re: [Quilt-dev] [patch 3/8] tac is not portable, Peter Williams, 2005/09/15
- Re: [Quilt-dev] [patch 3/8] tac is not portable, Gary V. Vaughan, 2005/09/15
- Re: [Quilt-dev] [patch 3/8] tac is not portable, Jean Delvare, 2005/09/15
- Re: [Quilt-dev] [patch 3/8] tac is not portable, Gary V. Vaughan, 2005/09/15
- Re: [Quilt-dev] [patch 3/8] tac is not portable, Jean Delvare, 2005/09/15
- Re: [Quilt-dev] [patch 3/8] tac is not portable, Gary V. Vaughan, 2005/09/15
- Re: [Quilt-dev] [patch 3/8] tac is not portable,
Dave Dodge <=
- Re: [Quilt-dev] [patch 3/8] tac is not portable, Jean Delvare, 2005/09/16
[Quilt-dev] [patch 2/8], gary, 2005/09/13
- Re: [Quilt-dev] [patch 2/8], John Vandenberg, 2005/09/13
- Re: [Quilt-dev] workaround "received broken pipe signal" bash bug (was [patch 2/8]), Gary V. Vaughan, 2005/09/14
- Re: [Quilt-dev] workaround "received broken pipe signal" bash bug (was [patch 2/8]), John Vandenberg, 2005/09/14
- Re: [Quilt-dev] workaround "received broken pipe signal" bash bug (was [patch 2/8]), Andreas Gruenbacher, 2005/09/14
- Re: [Quilt-dev] workaround "received broken pipe signal" bash bug (was [patch 2/8]), Jean Delvare, 2005/09/14
- Re: [Quilt-dev] workaround "received broken pipe signal" bash bug (was [patch 2/8]), Gary V. Vaughan, 2005/09/14
- Re: [Quilt-dev] workaround "received broken pipe signal" bash bug (was [patch 2/8]), Jean Delvare, 2005/09/14
Re: [Quilt-dev] [patch 2/8], Jean Delvare, 2005/09/14