From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7660 invoked by alias); 20 Jul 2014 16:09:34 -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: 18973 Received: (qmail 12724 invoked from network); 20 Jul 2014 16:09:32 -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 autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <140720090911.ZM8019@torch.brasslantern.com> Date: Sun, 20 Jul 2014 09:09:10 -0700 In-reply-to: Comments: In reply to Thorsten Kampe "Global xtrace from function" (Jul 20, 5:20pm) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: Global xtrace from function MIME-version: 1.0 Content-type: text/plain; charset=us-ascii 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 ...