[hq4ever@maxim-ws InitScripts]$ cat trapsh.sh #!/bin/bash set -x trap "echo retval = $?" ERR echo "pid is $$" while : # This is the same as "while true". do sleep 5 # This script is not really doing anything. mount /home/king done [hq4ever@maxim-ws InitScripts]$ [hq4ever@maxim-ws InitScripts]$ [hq4ever@maxim-ws InitScripts]$ ./trapsh.sh + trap 'echo retval = 0' ERR + echo 'pid is 735' pid is 735 + : + sleep 5 + mount /home/king mount: can't find /home/king in /etc/fstab or /etc/mtab ++ echo retval = 0 retval = 0 + : + sleep 5 [hq4ever@maxim-ws InitScripts]$ mount /home/king mount: can't find /home/king in /etc/fstab or /etc/mtab [hq4ever@maxim-ws InitScripts]$ echo $? 1