summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/exec.c6
-rw-r--r--Test/E02xtrace.ztst9
3 files changed, 20 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 3b82468c7..a9bf59c5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-12-26 Daniel Shahaf <danielsh@apache.org>
+
+ * 45131: Src/exec.c, Test/E02xtrace.ztst: Make a function that
+ redefines itself preserve its tracedness.
+
2019-12-23 Daniel Shahaf <danielsh@apache.org>
* unposted: Completion/Unix/Command/_stdbuf: Fix mismatch
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);
}
}
diff --git a/Test/E02xtrace.ztst b/Test/E02xtrace.ztst
index da6191cd0..8d2c300cf 100644
--- a/Test/E02xtrace.ztst
+++ b/Test/E02xtrace.ztst
@@ -146,3 +146,12 @@
?+(anon):0> '(anon)'
?+(anon):0> true
?+fn:0> gn
+
+ f() {
+ f() { echo inner }
+ }
+ functions -T f
+ f
+ which f | grep '# traced'
+0:a function that redefines itself preserves tracing
+> # traced