Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[BUG] ignored trap and subshell
- X-seq: zsh-workers 49302
- From: Vincent Lefevre <vincent@xxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [BUG] ignored trap and subshell
- Date: Tue, 24 Aug 2021 18:23:30 +0200
- Archived-at: <https://zsh.org/workers/49302>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: zsh-workers@xxxxxxx
The zshmisc(1) man page says:
( list )
Execute list in a subshell. Traps set by the trap builtin are
reset to their default values while executing list.
However, with "emulate sh", ignored traps should still be ignored
in the subshell according to POSIX, and zsh 5.8 fails do conform:
$ zsh -c 'emulate sh; trap "" INT; trap; echo A; ( trap; echo B; sleep 3; ); echo $?'
trap -- '' INT
A
B
^C130
where Ctrl-C immediately interrupts the sleep.
Compare to sh:
$ sh -c 'trap "" INT; trap; echo A; ( trap; echo B; sleep 3; ); echo $?'
trap -- '' INT
A
trap -- '' INT
B
^C0
where the sleep isn't interrupted by Ctrl-C.
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author