From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27248 invoked by alias); 20 Jul 2014 16:21:02 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18975 Received: (qmail 10960 invoked from network); 20 Jul 2014 16:20:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-users@zsh.org From: Thorsten Kampe Subject: Re: Global xtrace from function Date: Sun, 20 Jul 2014 18:20:23 +0200 Message-ID: References: <140720090911.ZM8019@torch.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: p579b3835.dip0.t-ipconnect.de User-Agent: MicroPlanet-Gravity/3.0.4 * Bart Schaefer (Sun, 20 Jul 2014 09:09:10 -0700) > > On Jul 20, 5:20pm, Thorsten Kampe wrote: > } > } is it possible to `setopt xtrace` from within a function without > } having xtrace unset when exiting the function? That seems to be the > } default behaviour for Bash's `shopt -os xtrace`. > > The options XTRACE, PRINT_EXIT_VALUE, LOCAL_OPTIONS, and LOCAL_LOOPS > are always reset on exit from a function. (I'm not sure why the > LOCAL_TRAPS and LOCAL_PATTERNS options aren't in that list as well, > except "because they're newer and nobody thought of it.") Zsh has > behaved this way since before the source was under version control. > > It's possible that we ought to skip resetting xtrace when in posix > shell emulation mode. > > You can get the effect you want with > > this_sets_xtrace() { trap 'setopt xtrace' EXIT } > > except of course in posix emulation (POSIX_TRAPS), when exit traps > aren't executed for shell functions ... Works beautifully, thanks!