zsh-workers
 help / color / mirror / code / Atom feed
* [BUG] ignored trap and subshell
@ 2021-08-24 16:23 Vincent Lefevre
  2021-08-24 17:29 ` Bart Schaefer
  2021-08-25 10:10 ` Peter Stephenson
  0 siblings, 2 replies; 6+ messages in thread
From: Vincent Lefevre @ 2021-08-24 16:23 UTC (permalink / raw)
  To: zsh-workers

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@vinc17.net> - 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)


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-08-25 16:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 16:23 [BUG] ignored trap and subshell Vincent Lefevre
2021-08-24 17:29 ` Bart Schaefer
2021-08-24 17:33   ` Bart Schaefer
2021-08-25 10:10 ` Peter Stephenson
2021-08-25 10:47   ` Peter Stephenson
2021-08-25 16:07     ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).