From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28697 invoked by alias); 10 Feb 2017 15:17:32 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 40516 Received: (qmail 14145 invoked from network); 10 Feb 2017 15:17:32 -0000 X-Qmail-Scanner-Diagnostics: from 195.159.176.226 by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(195.159.176.226):SA:0(2.5/5.0):. Processed in 1.519019 secs); 10 Feb 2017 15:17:32 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: ** X-Spam-Status: No, score=2.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, NML_ADSP_CUSTOM_MED,RDNS_NONE autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: gcszd-zsh-workers@m.gmane.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at m.gmane.org does not designate permitted sender hosts) X-Injected-Via-Gmane: http://gmane.org/ To: zsh-workers@zsh.org From: Stephane Chazelas Subject: traps not reset in pipe component subshells Date: Fri, 10 Feb 2017 14:57:12 +0000 Message-ID: <20170210145712.GA16061@chaz.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@blaine.gmane.org User-Agent: Mutt/1.5.24 (2015-08-30) Content-Disposition: inline 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