вот это одна из причин, за что я не люблю конвейеры.
если речь о bash, то вот что в мане:
The return status of a pipeline is the exit status of the last command, unless the pipefail
option is enabled. If pipefail is enabled, the pipeline's return status is the value of the
last (rightmost) command to exit with a non-zero status, or zero if all commands exit success‐
fully. If the reserved word ! precedes a pipeline, the exit status of that pipeline is the
logical negation of the exit status as described above. The shell waits for all commands in
the pipeline to terminate before returning a value.
ну и да,
PIPESTATUS
An array variable (see Arrays below) containing a list of exit status values from the
processes in the most-recently-executed foreground pipeline (which may contain only a
single command).