R54 Judge a check by its exit status, never through a pipe

On by default

Run a check command on its own and judge it by its exit status, never piping its output into another command.

Reason

In a pipeline the shell reports the exit status of the last command, so a check that fails and is piped into a pager or a filter reads as passed; and an output that was cut or filtered can hide the line that shows the failure. A check read that way still passes when the error occurs, and is no evidence that the error is ruled out (Art. VII §2).

Verification

A check command is a command run to find out whether something passes or fails: a test run, a linter, a build, a run of the commit hooks, or a dry run. It runs as a command of its own, not as part of a pipeline, and its result is its exit status: 0 passes, anything else fails. When its output is too long to read, the whole command’s output is redirected to a file (<command> > <file> 2>&1), and the exit status is read on its own afterwards.

Violated when the result of a check is stated or acted on from a run in which its output was piped into another command, or from its output without its exit status.

Provisions of the constitution it cites

Relations

Parent
R15 Verification
Requires
none
Conflicts with
none

Metadata

ID
54
Revision
4
Kind
rule
Status
trial
Slug
check-exit-status
Default level
project
Constitution revisions
>=1
Check
none
Default
on
Uses
Instructions instructions
Original language
English en
Translations
Chinese zh