Skip to content

Files

Latest commit

 

History

History
36 lines (21 loc) · 846 Bytes

SC2176.md

File metadata and controls

36 lines (21 loc) · 846 Bytes

Pattern: Use of time with pipeline

Issue: -

Description

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.

Exceptions

None. This method is not given in ksh or bash where time is defined for pipelines.

Further Reading