about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorDaniel Shahaf <danielsh@apache.org>2019-12-22 04:52:38 +0000
committerDaniel Shahaf <danielsh@apache.org>2019-12-26 04:20:10 +0000
commitca6f4466e661f185d083e09c55fb93d16e0736cc (patch)
tree62dfdb74ae41e805376dfefc409ad8469a434750 /Src
parent3834c423ab293761471d57d2813528d3079cf051 (diff)
downloadzsh-ca6f4466e661f185d083e09c55fb93d16e0736cc.tar.gz
zsh-ca6f4466e661f185d083e09c55fb93d16e0736cc.tar.xz
zsh-ca6f4466e661f185d083e09c55fb93d16e0736cc.zip
45131: Make a function that redefines itself preserve its tracedness.
This makes it easy to apply local tracing ('functions -T') to autoloadable
functions that redefines themselves when first loaded.
Diffstat (limited to 'Src')
-rw-r--r--Src/exec.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Src/exec.c b/Src/exec.c
index fac095d64..356e2974b 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -5320,6 +5320,12 @@ execfuncdef(Estate state, Eprog redir_prog)
 		 */
 		removetrapnode(signum);
 	    }
+	    /* Is this function traced and redefining itself? */
+	    if (funcstack && funcstack->tp == FS_FUNC &&
+		    !strcmp(s, funcstack->name)) {
+		Shfunc old = ((Shfunc)shfunctab->getnode(shfunctab, s));
+		shf->node.flags |= old->node.flags & (PM_TAGGED|PM_TAGGED_LOCAL);
+	    }
 	    shfunctab->addnode(shfunctab, ztrdup(s), shf);
 	}
     }