1 # make sure subshells at the end of pipelines run any exit traps they set
3 : | { trap 'echo exit subshell 1' EXIT; exit; }; echo current shell
5 : | { trap 'echo exit subshell 2' EXIT; exit; }; echo current shell
7 : | { trap 'echo exit subshell 3' EXIT; exit; } | : ; echo current shell
9 : | { trap 'echo exit subshell 4' EXIT; exit; } | : ; echo current shell
11 trap 'echo inherited exit trap' EXIT
12 : | { exit; } ; echo outside 1
13 : | ( exit; ) ; echo outside 2
14 : | { exit; } | : ; echo outside 3
15 : | ( exit; ) | : ; echo outside 4
19 # make sure group commands that are not at the beginning or end of pipelines
20 # run an EXIT trap, with and without the exit builtin
23 trap 'echo "in trap EXIT">&2' EXIT
35 trap 'echo "in trap EXIT">&2' EXIT