* traps not reset in pipe component subshells
@ 2017-02-10 14:57 Stephane Chazelas
0 siblings, 0 replies; only message in thread
From: Stephane Chazelas @ 2017-02-10 14:57 UTC (permalink / raw)
To: zsh-workers
Hello,
$ zsh -c 'trap "print -u2 out" EXIT; exit | exit | exit'
out
out
out
That's the only case I could find where the traps are not reset
in a subshell (tried coproc, zpty, $(...), <(...), exit&)
Another POSIX non-conformance:
$ bash -c 'trap uname EXIT; echo "$(trap)"'
trap -- 'uname' EXIT
Linux
$ zsh -c 'trap uname EXIT; echo "$(trap)"'
Linux
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#trap
POSIX requires $(trap) be treated as a special case so one can do:
traps=$(trap)
...
eval "$traps" # restore earlier traps
dash and mksh have the same problem. In zsh, thanks to the
first /bug/ above, one can do:
trap | IFS= read -rd '' traps
It may make sense to have a $trap[NAL] zsh/parameter hash for
that (where an empty value means ignored, while "-" means
default, not sure what to do if there's a TRAPNAL() but an
application can always check $+functions[TRAPNAL] first).
See also:
https://unix.stackexchange.com/questions/343990/dash-how-to-capture-output-of-trap-invoked-w-o-arguments/343999#343999
--
Stephane
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-02-10 15:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-10 14:57 traps not reset in pipe component subshells Stephane Chazelas
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).