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

Re: PATCH: Add `sourcetrace' option



On Sun, 24 Jan 2010 01:18:16 +0100
Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx> wrote:
> Here's an updated patch. Thanks to everyone who reviewed the previous
> attempts.

I'm just toying with this variant...  the difference is this moves the
output down until after the script name etc. is set up, and uses PS4
(like the xtrace option), so the output is more configurable.  For
example, I get:

+/etc/zshenv:1> <sourcetrace>
+/home/pws/.zshenv:1> <sourcetrace>
+/home/pws/.profile:1> <sourcetrace>
+/home/pws/.zshrc:1> <sourcetrace>
/home/pws/.aliasrc:1:> <sourcetrace>
/home/pws/.compinstall:1:> <sourcetrace>
/home/pws/.zcompdump_4.3.10-dev-1_pws:1:> <sourcetrace>

(the change in the middle is because I tweak PS4 to remove the "+" in
.zshrc, for no good reason I can now think of, as well as adding %_, and
there's only one global file because .zshenv sets NO_GLOBAL_RCS.)

I'm not particularly set on this but it seems more powerful without
losing anything obvious.  The documentation would need tweaking.

Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.88
diff -u -r1.88 options.yo
--- Doc/Zsh/options.yo	13 Jan 2010 12:05:48 -0000	1.88
+++ Doc/Zsh/options.yo	24 Jan 2010 21:10:31 -0000
@@ -1584,6 +1584,16 @@
 component in `tt(08#77)' are always interpreted as decimal, regardless
 of leading zeroes.
 )
+pindex(SOURCE_TRACE)
+pindex(NO_SOURCE_TRACE)
+pindex(SOURCETRACE)
+pindex(NOSOURCETRACE)
+item(tt(SOURCE_TRACE))(
+If set, zsh will print an informational message announcing the name of
+each file it loads.  A file may be loaded by the shell itself when it
+starts up and shuts down (tt(Startup/Shutdown Files)) or by the use of
+the `tt(source)' and `tt(dot)' builtin commands.
+)
 pindex(TYPESET_SILENT)
 pindex(NO_TYPESET_SILENT)
 pindex(TYPESETSILENT)
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.108
diff -u -r1.108 init.c
--- Src/init.c	16 Dec 2009 18:39:07 -0000	1.108
+++ Src/init.c	24 Jan 2010 21:10:31 -0000
@@ -1126,6 +1126,11 @@
     scriptname = s;
     scriptfilename = s;
 
+    if (isset(SOURCETRACE)) {
+	printprompt4();
+	fprintf(xtrerr ? xtrerr : stderr, "<sourcetrace>\n");
+    }
+
     /*
      * The special return behaviour of traps shouldn't
      * trigger in files sourced from traps; the return
Index: Src/options.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/options.c,v
retrieving revision 1.52
diff -u -r1.52 options.c
--- Src/options.c	13 Jan 2010 12:05:49 -0000	1.52
+++ Src/options.c	24 Jan 2010 21:10:31 -0000
@@ -233,6 +233,7 @@
 {{NULL, "shwordsplit",	      OPT_EMULATE|OPT_BOURNE},	 SHWORDSPLIT},
 {{NULL, "singlecommand",      OPT_SPECIAL},		 SINGLECOMMAND},
 {{NULL, "singlelinezle",      OPT_KSH},			 SINGLELINEZLE},
+{{NULL, "sourcetrace",        0},			 SOURCETRACE},
 {{NULL, "sunkeyboardhack",    0},			 SUNKEYBOARDHACK},
 {{NULL, "transientrprompt",   0},			 TRANSIENTRPROMPT},
 {{NULL, "trapsasync",	      0},			 TRAPSASYNC},
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.161
diff -u -r1.161 zsh.h
--- Src/zsh.h	19 Jul 2009 19:08:54 -0000	1.161
+++ Src/zsh.h	24 Jan 2010 21:10:32 -0000
@@ -1999,6 +1999,7 @@
     SHWORDSPLIT,
     SINGLECOMMAND,
     SINGLELINEZLE,
+    SOURCETRACE,
     SUNKEYBOARDHACK,
     TRANSIENTRPROMPT,
     TRAPSASYNC,

-- 
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