Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Global xtrace from function
- X-seq: zsh-users 18973
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Global xtrace from function
- Date: Sun, 20 Jul 2014 09:09:10 -0700
- In-reply-to: <lqgmop$5q7$1@ger.gmane.org>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <lqgmop$5q7$1@ger.gmane.org>
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 ...
Messages sorted by:
Reverse Date,
Date,
Thread,
Author