1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
subshell exit
trap -- 'echo exiting' EXIT
trap -- 'echo aborting' SIGHUP
trap -- 'echo aborting' SIGINT
trap -- 'echo aborting' SIGQUIT
trap -- 'echo aborting' SIGABRT
trap -- 'echo aborting' SIGTERM
[33] debug
debug line
[35] debug
trap -- 'echo exiting' EXIT
trap -- 'echo aborting' SIGHUP
trap -- 'echo aborting' SIGINT
trap -- 'echo aborting' SIGQUIT
trap -- 'echo aborting' SIGABRT
trap -- 'echo aborting' SIGTERM
trap -- 'echo [$LINENO] debug' DEBUG
[37] debug
func[29] funcdebug
funcdebug line
./trap.tests[39] funcdebug
trap -- 'echo exiting' EXIT
trap -- 'echo aborting' SIGHUP
trap -- 'echo aborting' SIGINT
trap -- 'echo aborting' SIGQUIT
trap -- 'echo aborting' SIGABRT
trap -- 'echo aborting' SIGTERM
trap -- 'echo ${FUNCNAME:-$0}[$LINENO] funcdebug' DEBUG
./trap.tests[41] funcdebug
./trap.tests[46] debug
./trap.tests[47] debug
func2[43] debug
func2[44] debug
func2debug line
./trap.tests[49] debug
./trap.tests[51] debug
trap -- 'echo exiting' EXIT
trap -- 'echo aborting' SIGHUP
trap -- 'echo aborting' SIGINT
trap -- 'echo aborting' SIGQUIT
trap -- 'echo aborting' SIGABRT
trap -- 'echo aborting' SIGTERM
trap -- '' DEBUG
trap -- 'echo exiting' EXIT
trap -- 'echo aborting' SIGHUP
trap -- 'echo aborting' SIGINT
trap -- 'echo aborting' SIGQUIT
trap -- 'echo aborting' SIGABRT
trap -- 'echo aborting' SIGTERM
trap -- 'echo exiting' EXIT
trap -- '' SIGINT
trap -- 'echo aborting' SIGQUIT
trap -- 'echo aborting' SIGABRT
trap -- 'echo aborting' SIGTERM
0
trap -- '' SIGUSR2
ERRTRAP
ERRTRAP
ERRTRAP
after falses
if negation ok
after negation
after while
before false in trap2a.sub
after false in trap2a.sub
command substitution
ERRTRAP
ERRTRAP
bar
ERRTRAP
ERRTRAP
ERRTRAP
ERRTRAP
ERRTRAP
+[6] echo 1
1
+[7] echo 2
2
+[8] false
+[8] false
+[8] false
++[8] echo trap: 8
trap: 8
+[9] echo 4
4
exit subshell 1
current shell
exit subshell 2
current shell
current shell
current shell
outside 1
outside 2
outside 3
outside 4
sleep 2
wait $!
exit
in trap EXIT
sleep 2
wait $!
exit
in trap EXIT
fn
after 1
fn
after 2
declare -- baz=$'bar\nfoo'
before
after
CHLD
CHLD
CHLD
CHLD
BASH_TRAPSIG = USR1
func=7
222
exit=0
exit=0
A
In trap-argument: last command preceding the trap action
In a function call: last command in the trap action
caught a child death
caught a child death
caught a child death
trap -- 'echo caught a child death' SIGCHLD
echo caught a child death
./trap.tests: line 118: trap: cannot specify both -p and -P
./trap.tests: line 119: trap: -P requires at least one signal name
trap: usage: trap [-Plp] [[action] signal_spec ...]
./trap.tests: line 121: trap: -x: invalid option
trap: usage: trap [-Plp] [[action] signal_spec ...]
trap -- 'echo exiting' EXIT
trap -- 'echo aborting' SIGABRT
trap -- 'echo caught a child death' SIGCHLD
trap: usage: trap [-Plp] [[action] signal_spec ...]
echo exiting
exiting
|