Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[BUG] ignored trap and subshell



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