Pattern: Use of time
with pipeline
Issue: -
This behavior is explicitly left undefined in POSIX.
Example of incorrect code:
time foo | bar```
Example of **correct** code:
To time the most relevant stage:
```sh
foo | { time bar; }
To time everything in a pipeline:
time bash -c 'foo | bar'
Note that you can not time sh -c
to time an entire pipeline, because POSIX does not guarantee that anything other than the last stage is waited on and therefore be recursively counted in the times()
call that time
depends on.
None. This method is not given in ksh
or bash
where time
is defined for pipelines.