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

Re: PATCH: pws-24: prompt escapes for script/function and lineno



"Andrej Borsenkow" wrote:
> >
> > > Maybe we should make '+%N:%i:%_> ' or something such the default PS4?
> 
> Probably, %_ is a bit overkill. I tried it, and the resulting output is hard 
> to
> read (mostly, because executed lines are no more aligned).
> 
> I would suggest just '+%N:%i> '. It gives enough information to track down
> problems.

OK, this makes sense --- %N:%i is certainly unambiguous, and `content over
form' is the zsh motto.  (All right, that was a lie.)  It's already long
enough when you have lines like

+/usr/local/lib/hepix/shells/site/aliases.sh:54> [ -r /u/theor/pubtheor/group_aliases.sh ]

being executed by zsh -f.

The default stays the same for sh and ksh emulations where promptpercent is
not set.

Another similar thing:  It would be clearer to have xtrace output for `for'
and `case' statements, to show what is being assigned to, or what is being
tested against what.  Any suggestions for an output format (xtrace doesn't
usually show the full gory shell syntax)?

--- Doc/Zsh/params.yo.ps4	Mon Jun 28 10:57:32 1999
+++ Doc/Zsh/params.yo	Mon Jun 28 19:01:59 1999
@@ -650,7 +650,9 @@
 )
 vindex(PS4)
 item(tt(PS4) <S>)(
-The execution trace prompt.  Default is `tt(PLUS() )'.
+The execution trace prompt.  Default is `tt(PLUS()%N:%i> )', which displays
+the name of the current shell structure and the line number within it.
+In sh or ksh emulation, the default is `tt(PLUS() )'.
 )
 vindex(PROMPT)
 xitem(tt(PROMPT) <S> <Z>)
--- Doc/Zsh/prompt.yo.ps4	Mon Jun 28 10:30:26 1999
+++ Doc/Zsh/prompt.yo	Mon Jun 28 18:44:07 1999
@@ -132,7 +132,9 @@
 The status of the parser, i.e. the shell constructs (like `tt(if)' and
 `tt(for)') that have been started on the command line. If given an integer
 number that many strings will be printed; zero or no integer means
-print as many as there are.
+print as many as there are.  This is most useful in prompts tt(PS2) for
+continuation lines and tt(PS4) for debugging with the tt(XTRACE) option; in
+the latter case it will also work non-interactively.
 )
 item(tt(%E))(
 Clears to end of line.
--- Src/init.c.ps4	Sat Jun 26 15:58:22 1999
+++ Src/init.c	Mon Jun 28 18:42:21 1999
@@ -624,7 +624,8 @@
 	prompt2 = ztrdup("%_> ");
     }
     prompt3 = ztrdup("?# ");
-    prompt4 = ztrdup("+ ");
+    prompt4 = (emulation == EMULATE_KSH || emulation == EMULATE_SH)
+	? ztrdup("+ ") : ztrdup("+%N:%i> ");
     sprompt = ztrdup("zsh: correct '%R' to '%r' [nyae]? ");
 
     ifs         = ztrdup(DEFAULT_IFS);

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



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