about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2012-08-21 18:03:01 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2012-08-21 18:03:01 +0000
commit6f3ff6b653ca5e6f528bc46ec6295cb6d263a9fd (patch)
tree5597e80a02d420f2ec6543f6dff0e21e14064b1b
parent07fd604718b0b2202808c121f7bbcb4dce5c9ae5 (diff)
downloadzsh-6f3ff6b653ca5e6f528bc46ec6295cb6d263a9fd.tar.gz
zsh-6f3ff6b653ca5e6f528bc46ec6295cb6d263a9fd.tar.xz
zsh-6f3ff6b653ca5e6f528bc46ec6295cb6d263a9fd.zip
30633: "functions -T" only traces marked function, not called functions
-rw-r--r--ChangeLog9
-rw-r--r--Doc/Zsh/builtins.yo25
-rw-r--r--Src/builtin.c8
-rw-r--r--Src/exec.c15
-rw-r--r--Src/hashtable.c7
-rw-r--r--Src/options.c2
-rw-r--r--Src/subst.c2
-rw-r--r--Src/zsh.h1
8 files changed, 49 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index a2b415d83..78e4f92f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-08-21  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 30633: Doc/Zsh/builtins.yo, Src/builtin.c, Src/exec.c,
+	Src/hashtable.c, Src/options.c, Src/subst.c, Src/zsh.h:
+	"functions -T" traces only marked function and not called
+	functions unless also marked.
+
 2012-08-20  Peter Stephenson  <pws@csr.com>
 
 	* Stepan Koltsov: 30634: Functions/Misc/zmv: use (q-) quoting
@@ -88,5 +95,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5704 $
+* $Revision: 1.5705 $
 *****************************************************
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 894f65a3e..0e5353633 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -620,7 +620,7 @@ Equivalent to tt(typeset -E), except that options irrelevant to floating
 point numbers are not permitted.
 )
 findex(functions)
-xitem(tt(functions) [ {tt(PLUS())|tt(-)}tt(UXkmtuz) ] [ var(name) ... ])
+xitem(tt(functions) [ {tt(PLUS())|tt(-)}tt(UXkmtTuz) ] [ var(name) ... ])
 xitem(tt(functions -M) var(mathfn) [ var(min) [ var(max) [ var(shellfn) ] ] ])
 xitem(tt(functions -M) [ tt(-m) var(pattern) ... ])
 item(tt(functions +M) [ tt(-m) ] var(mathfn))(
@@ -1555,6 +1555,7 @@ export.  Setting the value using the scalar version causes a split on all
 separators (which cannot be quoted).  It is possible to use the
 same two tied variables with a different separator character in which
 case the variables remain joined as before but the separator is changed.
+This flag has a different meaning when used with tt(-f); see below.
 
 The tt(-g) (global) flag is treated specially: it means that any
 resulting parameter will not be restricted to local scope.  Note that this
@@ -1652,16 +1653,18 @@ shown.
 )
 item(tt(-f))(
 The names refer to functions rather than parameters.  No assignments
-can be made, and the only other valid flags are tt(-t), tt(-k), tt(-u),
-tt(-U) and tt(-z).  The flag tt(-t) turns on execution tracing for this
-function.  The tt(-u) and tt(-U) flags cause the function to be
-marked for autoloading; tt(-U) also causes alias expansion to be
-suppressed when the function is loaded.  The tt(fpath) parameter
-will be searched to find the function definition when the function
-is first referenced; see noderef(Functions). The tt(-k) and tt(-z) flags
-make the function be loaded using ksh-style or zsh-style autoloading
-respectively. If neither is given, the setting of the KSH_AUTOLOAD option
-determines how the function is loaded.
+can be made, and the only other valid flags are tt(-t), tt(-T), tt(-k),
+tt(-u), tt(-U) and tt(-z).  The flag tt(-t) turns on execution tracing
+for this function; the flag tt(-T) does the same, but turns off tracing
+on any function called from the present one, unless that function also
+has the tt(-t) or tt(-T) flag.  The tt(-u) and tt(-U) flags cause the
+function to be marked for autoloading; tt(-U) also causes alias
+expansion to be suppressed when the function is loaded.  The tt(fpath)
+parameter will be searched to find the function definition when the
+function is first referenced; see noderef(Functions). The tt(-k) and
+tt(-z) flags make the function be loaded using ksh-style or zsh-style
+autoloading respectively. If neither is given, the setting of the
+KSH_AUTOLOAD option determines how the function is loaded.
 )
 item(tt(-h))(
 Hide: only useful for special parameters (those marked `<S>' in the table in
diff --git a/Src/builtin.c b/Src/builtin.c
index ce7d6a563..3925edd10 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -46,7 +46,7 @@ static struct builtin builtins[] =
     BUILTIN(".", BINF_PSPECIAL, bin_dot, 1, -1, 0, NULL, NULL),
     BUILTIN(":", BINF_PSPECIAL, bin_true, 0, -1, 0, NULL, NULL),
     BUILTIN("alias", BINF_MAGICEQUALS | BINF_PLUSOPTS, bin_alias, 0, -1, 0, "Lgmrs", NULL),
-    BUILTIN("autoload", BINF_PLUSOPTS, bin_functions, 0, -1, 0, "ktUwXz", "u"),
+    BUILTIN("autoload", BINF_PLUSOPTS, bin_functions, 0, -1, 0, "ktTUwXz", "u"),
     BUILTIN("bg", 0, bin_fg, 0, -1, BIN_BG, NULL, NULL),
     BUILTIN("break", BINF_PSPECIAL, bin_break, 0, 1, BIN_BREAK, NULL, NULL),
     BUILTIN("bye", 0, bin_break, 0, 1, BIN_EXIT, NULL, NULL),
@@ -72,7 +72,7 @@ static struct builtin builtins[] =
     BUILTIN("fc", 0, bin_fc, 0, -1, BIN_FC, "aAdDe:EfiIlmnpPrRt:W", NULL),
     BUILTIN("fg", 0, bin_fg, 0, -1, BIN_FG, NULL, NULL),
     BUILTIN("float", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "E:%F:%HL:%R:%Z:%ghlprtux", "E"),
-    BUILTIN("functions", BINF_PLUSOPTS, bin_functions, 0, -1, 0, "kmMtuUz", NULL),
+    BUILTIN("functions", BINF_PLUSOPTS, bin_functions, 0, -1, 0, "kmMtTuUz", NULL),
     BUILTIN("getln", 0, bin_read, 0, -1, 0, "ecnAlE", "zr"),
     BUILTIN("getopts", 0, bin_getopts, 2, -1, 0, NULL, NULL),
     BUILTIN("hash", BINF_MAGICEQUALS, bin_hash, 0, -1, 0, "Ldfmrv", NULL),
@@ -2685,6 +2685,10 @@ bin_functions(char *name, char **argv, Options ops, int func)
 	on |= PM_TAGGED;
     else if (OPT_PLUS(ops,'t'))
 	off |= PM_TAGGED;
+    if (OPT_MINUS(ops,'T'))
+	on |= PM_TAGGED_LOCAL;
+    else if (OPT_PLUS(ops,'T'))
+	on |= PM_TAGGED_LOCAL;
     if (OPT_MINUS(ops,'z')) {
 	on |= PM_ZSHSTORED;
 	off |= PM_KSHSTORED;
diff --git a/Src/exec.c b/Src/exec.c
index 6ebc9c014..a40838f91 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -4484,11 +4484,12 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
     int *oldpipestats = NULL;
     char saveopts[OPT_SIZE], *oldscriptname = scriptname;
     char *name = shfunc->node.nam;
-    int flags = shfunc->node.flags;
+    int flags = shfunc->node.flags, ooflags;
     char *fname = dupstring(name);
     int obreaks, saveemulation, savesticky_emulation, restore_sticky;
     Eprog prog;
     struct funcstack fstack;
+    static int oflags;
 #ifdef MAX_FUNCTION_DEPTH
     static int funcdepth;
 #endif
@@ -4547,8 +4548,17 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
     } else
 	restore_sticky = 0;
 
-    if (flags & PM_TAGGED)
+    if (flags & (PM_TAGGED|PM_TAGGED_LOCAL))
 	opts[XTRACE] = 1;
+    else if (oflags & PM_TAGGED_LOCAL)
+	opts[XTRACE] = 0;
+    ooflags = oflags;
+    /*
+     * oflags is static, because we compare it on the next recursive
+     * call.  Hence also we maintain ooflags for restoring the previous
+     * value of oflags after the call.
+     */
+    oflags = flags;
     opts[PRINTEXITVALUE] = 0;
     if (doshargs) {
 	LinkNode node;
@@ -4633,6 +4643,7 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
     optcind = oldoptcind;
     zoptind = oldzoptind;
     scriptname = oldscriptname;
+    oflags = ooflags;
 
     if (restore_sticky) {
 	/*
diff --git a/Src/hashtable.c b/Src/hashtable.c
index be71a1cc9..b472e40b9 100644
--- a/Src/hashtable.c
+++ b/Src/hashtable.c
@@ -923,12 +923,13 @@ printshfuncnode(HashNode hn, int printflags)
 	    printf("%c undefined\n\t", hashchar);
 	else
 	    t = getpermtext(f->funcdef, NULL, 1);
-	if (f->node.flags & PM_TAGGED)
+	if (f->node.flags & (PM_TAGGED|PM_TAGGED_LOCAL))
 	    printf("%c traced\n\t", hashchar);
 	if (!t) {
-	    char *fopt = "Utkz";
+	    char *fopt = "UtTkz";
 	    int flgs[] = {
-		PM_UNALIASED, PM_TAGGED, PM_KSHSTORED, PM_ZSHSTORED, 0
+		PM_UNALIASED, PM_TAGGED, PM_TAGGED_LOCAL,
+		PM_KSHSTORED, PM_ZSHSTORED, 0
 	    };
 	    int fl;;
 
diff --git a/Src/options.c b/Src/options.c
index c6db75372..609c28fd1 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -532,7 +532,7 @@ emulate(const char *zsh_name, int fully)
 	 * close enough.
 	 */
 	Shfunc shf = (Shfunc)shfunctab->getnode(shfunctab, funcstack->name);
-	if (shf && (shf->node.flags & PM_TAGGED)) {
+	if (shf && (shf->node.flags & (PM_TAGGED|PM_TAGGED_LOCAL))) {
 	    /* Tracing is on, so set xtrace */
 	    opts[XTRACE] = 1;
 	}
diff --git a/Src/subst.c b/Src/subst.c
index 932f41287..b0c15d048 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2314,6 +2314,8 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
 		    val = dyncat(val, "-readonly");
 		if (f & PM_TAGGED)
 		    val = dyncat(val, "-tag");
+		if (f & PM_TAGGED_LOCAL)
+		    val = dyncat(val, "-tag_local");
 		if (f & PM_EXPORTED)
 		    val = dyncat(val, "-export");
 		if (f & PM_UNIQUE)
diff --git a/Src/zsh.h b/Src/zsh.h
index 946102528..b9f2846f7 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1554,6 +1554,7 @@ struct tieddata {
 #define PM_HIDE		(1<<14)	/* Special behaviour hidden by local        */
 #define PM_HIDEVAL	(1<<15)	/* Value not shown in `typeset' commands    */
 #define PM_TIED 	(1<<16)	/* array tied to colon-path or v.v.         */
+#define PM_TAGGED_LOCAL (1<<16) /* (function): non-recursive PM_TAGGED      */
 
 #define PM_KSHSTORED	(1<<17) /* function stored in ksh form              */
 #define PM_ZSHSTORED	(1<<18) /* function stored in zsh form              */