mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-06-06 05:32:04 +02:00
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.
This commit is contained in:
parent
3834c423ab
commit
ca6f4466e6
3 changed files with 20 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue