"
This leads to some irritating edge-cases if you forget this (or didn't realise it in the first place). Consider:
...and things only get worse if you actually start chaining things together...
Not perhaps the best design decision ever...
[1]
[2] See the "Pipelines" section in
time
" is a reserved keyword in bash
, not a builtin as one might naively expect[1,2]. Even more amusingly, many UN*X systems also have /usr/bin/time
which has rather less nice output. This leads to some irritating edge-cases if you forget this (or didn't realise it in the first place). Consider:
bash-3.2$ time sleep 1
real 0m1.009s
user 0m0.000s
sys 0m0.002s
bash-3.2$ FOO=bar time sleep 1
1.00 real 0.00 user 0.00 sys
bash-3.2$ time FOO=bar sleep 1
real 0m1.002s
user 0m0.000s
sys 0m0.002s
...and things only get worse if you actually start chaining things together...
bash-3.2$ time sleep 1 | time sleep 4
4.00 real 0.00 user 0.00 sys
real 0m4.004s
user 0m0.001s
sys 0m0.005s
Not perhaps the best design decision ever...
[1]
#chiark
thinks this was to make it possible to time entire pipelines, although there would be several obvious idioms for doing that if time
were a builtin[2] See the "Pipelines" section in
bash(1)
for more details
(no subject)
$ nice -19 time ./job-which-times-subjobs.sh
I've been running into recently.
(no subject)
$ time sleep 1 | { cat; sleep 1 } | cat
sleep 1 0.00s user 0.00s system 0% cpu 1.001 total
{; cat; sleep 1; } 0.00s user 0.00s system 0% cpu 2.003 total
cat 0.00s user 0.00s system 0% cpu 2.003 total
(no subject)