diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2012-03-01 13:00:52 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2012-03-01 13:00:52 +0000 |
commit | 7614be7fe1b9a9692a6c8f5c5f471df3ef288366 (patch) | |
tree | c15ae5cbd204d26d169923d72a72580a94864b60 | |
parent | 3c3d3dc92c3812a7e7de17200ac8a944ad2dea93 (diff) | |
download | zsh-7614be7fe1b9a9692a6c8f5c5f471df3ef288366.tar.gz zsh-7614be7fe1b9a9692a6c8f5c5f471df3ef288366.tar.xz zsh-7614be7fe1b9a9692a6c8f5c5f471df3ef288366.zip |
30303: emulate inside function marked for execution tracing enables xtrace
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | Doc/Zsh/builtins.yo | 7 | ||||
-rw-r--r-- | Src/options.c | 14 |
3 files changed, 27 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog index 9009bb157..867a702be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-03-01 Peter Stephenson <pws@csr.com> + + * 30303: Doc/builtins.yo, Src/options.c: emulate executed inside + a function marked for execution tracing enables xtrace. + 2012-02-29 Barton E. Schaefer <schaefer@zsh.org> * 30272 (tweaked): Src/exec.c: most failures of fork() cause @@ -16050,5 +16055,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5599 $ +* $Revision: 1.5600 $ ***************************************************** diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index 5d717479a..706c2803f 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -366,6 +366,13 @@ noderef(Compatibility) )\ . +If the tt(emulate) command occurs inside a function that has been +marked for execution tracing with tt(functions -t) then the tt(xtrace) +option will be turned on regardless of emulation mode or other options. +Note that code executed inside the function by the tt(.), tt(source), or +tt(eval) commands is not considered to be running directly from the +function, hence does not provoke this behaviour. + If the tt(-R) option is given, all options are reset to their default value corresponding to the specified emulation mode, except for certain options describing the interactive diff --git a/Src/options.c b/Src/options.c index 5fbb06b11..48df16045 100644 --- a/Src/options.c +++ b/Src/options.c @@ -523,6 +523,20 @@ emulate(const char *zsh_name, int fully) if (fully) emulation |= EMULATE_FULLY; installemulation(); + + if (funcstack && funcstack->tp == FS_FUNC) { + /* + * We are inside a function. Decide if it's traced. + * Pedantic note: the function in the function table isn't + * guaranteed to be what we're executing, but it's + * close enough. + */ + Shfunc shf = (Shfunc)shfunctab->getnode(shfunctab, funcstack->name); + if (shf && (shf->node.flags & PM_TAGGED)) { + /* Tracing is on, so set xtrace */ + opts[XTRACE] = 1; + } + } } /* setopt, unsetopt */ |