in reply to Re: Check system return codes
in thread Check system return codes
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.
|
|---|