function() { # some code echo $? # $? contains the return value of the command } return_value=function if [ $return_value -ne 0 ]; then # deal with error fi