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

PATCH: xtrace and zle



This changes the way `set -x' works when ZLE widgets are invoked.  First,
the default is to turn off the XTRACE option entirely for widgets (but not
for completion widgets, because of _complete_debug).  This avoids having a
lot of xtrace output garble the display during ordinary typing.

However, the per-function trace that can be set with `typeset -ft func' is
now respected (it previously was ignored), so if one really wants to trace
execution of a particular widget, one can still do so.  Note `typeset -ft'
is still ignored when executing completion widgets; that's another patch.

This seemed to me the most reasonable tradeoff between having ZLE become
completely unusable with `set -x' (think of the pain if one has installed
all the bash-compatibilty widgets that PWS recently posted) and enabling
debugging of widgets.

diff -u ../zsh-forge/current/Src/Zle/zle_main.c ./Src/Zle/zle_main.c
--- ../zsh-forge/current/Src/Zle/zle_main.c	Thu May 17 08:46:06 2001
+++ ./Src/Zle/zle_main.c	Fri Jul  6 20:35:36 2001
@@ -672,7 +672,8 @@
 	}
 	r = 1;
     } else {
-	Eprog prog = getshfunc(w->u.fnnam);
+	Shfunc shf = (Shfunc) shfunctab->getnode(shfunctab, w->u.fnnam);
+	Eprog prog = (shf ? shf->funcdef : &dummy_eprog);
 
 	if(prog == &dummy_eprog) {
 	    /* the shell function doesn't exist */
@@ -685,6 +686,7 @@
 	    ret = 1;
 	} else {
 	    int osc = sfcontext, osi = movefd(0), olv = lastval;
+	    int oxt = isset(XTRACE);
 	    LinkList largs = NULL;
 
 	    if (*args) {
@@ -696,7 +698,9 @@
 	    startparamscope();
 	    makezleparams(0);
 	    sfcontext = SFC_WIDGET;
-	    doshfunc(w->u.fnnam, prog, largs, 0, 0);
+	    opts[XTRACE] = 0;
+	    doshfunc(w->u.fnnam, prog, largs, shf->flags, 0);
+	    opts[XTRACE] = oxt;
 	    ret = lastval;
 	    lastval = olv;
 	    sfcontext = osc;

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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