source: trunk/third/bash/examples/functions/exitstat @ 21276

Revision 21276, 620 bytes checked in by zacheiss, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21275, which included commits to RCS files with non-trunk default branches.
Line 
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
Note: See TracBrowser for help on using the repository browser.