1# Contributed by Noah Friedman and Roland McGrath. 2 3# To be run by the PROMPT_COMMAND variable, so that one can see what 4# the exit status of processes are. 5 6function check_exit_status () 7{ 8 local status="$?" 9 local signal="" 10 11 if [ ${status} -ne 0 ] && [ ${status} != 128 ]; then 12 # If process exited by a signal, determine name of signal. 13 if [ ${status} -gt 128 ]; then 14 signal="$(builtin kill -l $((${status} - 128)) 2>/dev/null)" 15 if [ "$signal" ]; then signal="($signal)"; fi 16 fi 17 echo "[Exit ${status} ${signal}]" 1>&2 18 fi 19 return 0 20} 21 22PROMPT_COMMAND=check_exit_status 23