Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: core dump with prompt_subst and unusual PROMPT [4.3.2,4.2.6,4.2.1]



Matt Pharr wrote:
> If I source the following script (extracted from my .zshrc file), zsh  
> dumps core--I've reproduced this on 4.2.1, 4.2.6, and 4.3.2.   
> Admittedly it's pretty ugly and possibly malformed, though a core  
> dump's a core dump...  A representative stack trace (from 4.3.2) is  
> below.
> 
> thanks,
> -matt
> 
> --- snip ---
> PROMPT='[${{NKAPPDIR##/home/mmp/sw/}%%nkapp}] %(?..err %B%?%b )%(1v.%B 
> %v%b .)%B%#%b '

Thanks... it's actually just the prompt.  It's trying to warn you that
there's a bad substitution in the prompt (you're on your own there...),
and in order to warn you that it's having trouble with substitutions in
the prompt it needs to ensure that the zle display is in order, and to
do that it reexpands the prompt...  which is quite bad luck at this
point.

Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.85
diff -u -r1.85 zle_main.c
--- Src/Zle/zle_main.c	25 Apr 2006 15:00:27 -0000	1.85
+++ Src/Zle/zle_main.c	26 May 2006 22:36:41 -0000
@@ -1509,10 +1509,15 @@
 void
 reexpandprompt(void)
 {
-    free(lpromptbuf);
-    lpromptbuf = promptexpand(raw_lp ? *raw_lp : NULL, 1, NULL, NULL);
-    free(rpromptbuf);
-    rpromptbuf = promptexpand(raw_rp ? *raw_rp : NULL, 1, NULL, NULL);
+    static reexpanding;
+
+    if (!reexpanding++) {
+	free(lpromptbuf);
+	lpromptbuf = promptexpand(raw_lp ? *raw_lp : NULL, 1, NULL, NULL);
+	free(rpromptbuf);
+	rpromptbuf = promptexpand(raw_rp ? *raw_rp : NULL, 1, NULL, NULL);
+    }
+    reexpanding--;
 }
 
 /**/

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author