From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: zsh-workers@zsh.org
Subject: traps not reset in pipe component subshells
Date: Fri, 10 Feb 2017 14:57:12 +0000 [thread overview]
Message-ID: <20170210145712.GA16061@chaz.gmail.com> (raw)
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
reply other threads:[~2017-02-10 15:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170210145712.GA16061@chaz.gmail.com \
--to=stephane.chazelas@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).