bug-bash
[Top][All Lists]
Advanced

[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

Attachment: pgpxdAD8gq7Es.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]