Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

30303: emulate inside function marked for execution tracing enables x…

…trace
  • Loading branch information...
commit 7614be7fe1b9a9692a6c8f5c5f471df3ef288366 1 parent 3c3d3dc
Peter Stephenson authored
Showing with 27 additions and 1 deletion.
  1. +6 −1 ChangeLog
  2. +7 −0 Doc/Zsh/builtins.yo
  3. +14 −0 Src/options.c
View
7 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 $
*****************************************************
View
7 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
View
14 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 */
Please sign in to comment.
Something went wrong with that request. Please try again.