De link :
There is an internal Bash variable called
$PIPESTATUS; it’s an array that holds the exit status of each command in your last foreground pipeline of commands.<command> | tee out.txt ; test ${PIPESTATUS[0]} -eq 0Or another alternative which also works with other shells (like zsh) would be to enable pipefail:
set -o pipefail ...The first option does not work with
zshdue to a little bit different syntax.