If you use Bash then you can access the pipe return code using the array PIPESTATUS, recent Korn shell version support one called 'pipefail'With enough /bin/sh file descriptor fu, this can even be done using an ancient Bourne shell, as demonstrated by Tom Christiansen in a famous 1996 post, Csh Programming Considered Harmful. For example:
exec 3>&1 rc=`(($SOME_COMMAND 2>&1 3>&- 4>&-;echo $? 1>&4) | tee -a $LogFile 1>& +3 3>&- 4>&-) 4>&1` exec 3>&- # $rc has the return code of $SOME_COMMAND.
In reply to Re^2: Check system return codes
by eyepopslikeamosquito
in thread Check system return codes
by Noame
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |