about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Doc/Zsh/prompt.yo6
-rw-r--r--Src/prompt.c13
3 files changed, 24 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index b176ff863..3a2016e66 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
 	* 33062: Etc/zsh-development-guide: update note on use of
diff --git a/Doc/Zsh/prompt.yo b/Doc/Zsh/prompt.yo
index 0ed52b580..183a93a3b 100644
--- a/Doc/Zsh/prompt.yo
+++ b/Doc/Zsh/prompt.yo
@@ -108,6 +108,12 @@ the full path;
 ifzman(see em(Dynamic) and em(Static named directories) in zmanref(zshexpn))\
 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))
 item(tt(%!))(
 Current history event number.
diff --git a/Src/prompt.c b/Src/prompt.c
index 328ae3c66..47625351f 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -786,6 +786,19 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep)
 		if(bv->Rstring)
 		    stradd(bv->Rstring);
 		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':
 		if (funcstack && funcstack->tp != FS_SOURCE &&
 		    !IN_EVAL_TRAP()) {