1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-27 16:50:58 +01:00

33057: %e in prompts shows evaluation / execution depth

This commit is contained in:
Peter Stephenson 2014-08-29 09:46:34 +01:00
parent 40d559d880
commit 711e1427b5
3 changed files with 24 additions and 0 deletions

View file

@ -1,3 +1,8 @@
2014-08-29 Peter Stephenson <p.stephenson@samsung.com>
* 33057: Doc/Zsh/prompt.yo, Src/prompt.c: %e in prompts shows
evaluation / execution depth.
2014-08-28 Peter Stephenson <p.w.stephenson@ntlworld.com> 2014-08-28 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 33062: Etc/zsh-development-guide: update note on use of * 33062: Etc/zsh-development-guide: update note on use of

View file

@ -108,6 +108,12 @@ the full path;
ifzman(see em(Dynamic) and em(Static named directories) in zmanref(zshexpn))\ ifzman(see em(Dynamic) and em(Static named directories) in zmanref(zshexpn))\
ifnzman(noderef(Filename Expansion)). ifnzman(noderef(Filename Expansion)).
) )
item(tt(%e))(
Evaluation depth of the current sourced file, shell function, or tt(eval).
This is incremented or decremented every time the value of tt(%N) is
set or reverted to a previous value, respectively. This is most useful
for debugging as part of tt($PS4).
)
xitem(tt(%h)) xitem(tt(%h))
item(tt(%!))( item(tt(%!))(
Current history event number. Current history event number.

View file

@ -786,6 +786,19 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep)
if(bv->Rstring) if(bv->Rstring)
stradd(bv->Rstring); stradd(bv->Rstring);
break; break;
case 'e':
{
int depth = 0;
Funcstack fsptr = funcstack;
while (fsptr) {
depth++;
fsptr = fsptr->prev;
}
addbufspc(DIGBUFSIZE);
sprintf(bv->bp, "%d", depth);
bv->bp += strlen(bv->bp);
break;
}
case 'I': case 'I':
if (funcstack && funcstack->tp != FS_SOURCE && if (funcstack && funcstack->tp != FS_SOURCE &&
!IN_EVAL_TRAP()) { !IN_EVAL_TRAP()) {