Help for this page
(/bin/foo ; echo $? >RES)| tee -a $LOGFILE export ERR=$(cat RES)
$ cat test #!/bin/bash ... 1 0 # (so ${PIPESTATUS[0]} should give you the return of the first comma +nd).