[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Q: bash: trap in subshell
From: |
Dmitry V. Levin |
Subject: |
Q: bash: trap in subshell |
Date: |
Thu, 24 Apr 2008 19:40:01 +0400 |
Hi,
I wonder whether such difference in "trap" behavior is valid:
$ sh -c 'f() { echo f; }; t() { trap f EXIT; trap; }; t'
trap -- 'f' EXIT
f
$ sh -c 'f() { echo f; }; t() { trap f EXIT; trap; }; t&'
trap -- 'f' EXIT
$ sh -c 'f() { echo f; }; t() { trap f EXIT; trap; }; (t)&'
trap -- 'f' EXIT
f
Other shells (e.g. dash, zsh) demonstrate no such difference:
$ ash -c 'f() { echo f; }; t() { trap f EXIT; trap; }; t'
trap -- 'f' EXIT
f
$ ash -c 'f() { echo f; }; t() { trap f EXIT; trap; }; t&'
trap -- 'f' EXIT
f
$ ash -c 'f() { echo f; }; t() { trap f EXIT; trap; }; (t)&'
trap -- 'f' EXIT
f
--
ldv
pgp9Fi_INfhrD.pgp
Description: PGP signature
- Q: bash: trap in subshell,
Dmitry V. Levin <=