summaryrefslogtreecommitdiff
path: root/tests/trap4.sub
diff options
context:
space:
mode:
Diffstat (limited to 'tests/trap4.sub')
-rw-r--r--tests/trap4.sub25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/trap4.sub b/tests/trap4.sub
index 6a8abdac..ab5ca3e3 100644
--- a/tests/trap4.sub
+++ b/tests/trap4.sub
@@ -15,3 +15,28 @@ trap 'echo inherited exit trap' EXIT
: | ( exit; ) | : ; echo outside 4
trap - EXIT
+
+# make sure group commands that are not at the beginning or end of pipelines
+# run an EXIT trap, with and without the exit builtin
+echo ignored |
+{
+ trap 'echo "in trap EXIT">&2' EXIT
+ sleep 4 &
+ echo 'sleep 2'>&2
+ sleep 2
+ echo 'wait $!'>&2
+ wait $!
+ echo 'exit'>&2
+ exit
+} | cat
+
+echo ignored |
+{
+ trap 'echo "in trap EXIT">&2' EXIT
+ sleep 4 &
+ echo 'sleep 2'>&2
+ sleep 2
+ echo 'wait $!'>&2
+ wait $!
+ echo 'exit'>&2
+} | cat