Você quer set -o pipefail
.
Na página de manual do Bash:
pipefail
If set, the return value of a pipeline is the value of
the last (rightmost) command to exit with a non-zero status,
or zero if all commands in the pipeline exit successfully.
This option is disabled by default.