Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…trace
  • Loading branch information...
commit 7614be7fe1b9a9692a6c8f5c5f471df3ef288366 1 parent 3c3d3dc
Peter Stephenson authored

Showing 3 changed files with 27 additions and 1 deletion. Show diff stats Hide diff stats

  1. +6 1 ChangeLog
  2. +7 0 Doc/Zsh/builtins.yo
  3. +14 0 Src/options.c
7 ChangeLog
... ... @@ -1,3 +1,8 @@
  1 +2012-03-01 Peter Stephenson <pws@csr.com>
  2 +
  3 + * 30303: Doc/builtins.yo, Src/options.c: emulate executed inside
  4 + a function marked for execution tracing enables xtrace.
  5 +
1 6 2012-02-29 Barton E. Schaefer <schaefer@zsh.org>
2 7
3 8 * 30272 (tweaked): Src/exec.c: most failures of fork() cause
@@ -16050,5 +16055,5 @@
16050 16055
16051 16056 *****************************************************
16052 16057 * This is used by the shell to define $ZSH_PATCHLEVEL
16053   -* $Revision: 1.5599 $
  16058 +* $Revision: 1.5600 $
16054 16059 *****************************************************
7 Doc/Zsh/builtins.yo
@@ -366,6 +366,13 @@ noderef(Compatibility)
366 366 )\
367 367 .
368 368
  369 +If the tt(emulate) command occurs inside a function that has been
  370 +marked for execution tracing with tt(functions -t) then the tt(xtrace)
  371 +option will be turned on regardless of emulation mode or other options.
  372 +Note that code executed inside the function by the tt(.), tt(source), or
  373 +tt(eval) commands is not considered to be running directly from the
  374 +function, hence does not provoke this behaviour.
  375 +
369 376 If the tt(-R) option is given, all options
370 377 are reset to their default value corresponding to the specified emulation
371 378 mode, except for certain options describing the interactive
14 Src/options.c
@@ -523,6 +523,20 @@ emulate(const char *zsh_name, int fully)
523 523 if (fully)
524 524 emulation |= EMULATE_FULLY;
525 525 installemulation();
  526 +
  527 + if (funcstack && funcstack->tp == FS_FUNC) {
  528 + /*
  529 + * We are inside a function. Decide if it's traced.
  530 + * Pedantic note: the function in the function table isn't
  531 + * guaranteed to be what we're executing, but it's
  532 + * close enough.
  533 + */
  534 + Shfunc shf = (Shfunc)shfunctab->getnode(shfunctab, funcstack->name);
  535 + if (shf && (shf->node.flags & PM_TAGGED)) {
  536 + /* Tracing is on, so set xtrace */
  537 + opts[XTRACE] = 1;
  538 + }
  539 + }
526 540 }
527 541
528 542 /* setopt, unsetopt */

0 comments on commit 7614be7

Please sign in to comment.
Something went wrong with that request. Please try again.