zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: One last (?!?) tweak to xtrace redirection
@ 2000-03-15 17:36 Bart Schaefer
  0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2000-03-15 17:36 UTC (permalink / raw)
  To: zsh-workers

Saving and restoring of the xtrace descriptor should not occur until xtrace
is actually turned on.

Index: Src/exec.c
===================================================================
@@ -2012,7 +2012,8 @@
 
     /* Make a copy of stderr for xtrace output before redirecting */
     fflush(xtrerr);
-    if (xtrerr == stderr && (type < WC_SUBSH || type == WC_TIMED)) {
+    if (isset(XTRACE) && xtrerr == stderr &&
+	(type < WC_SUBSH || type == WC_TIMED)) {
 	if (!(xtrerr = fdopen(movefd(dup(fileno(stderr))), "w")))
 	    xtrerr = stderr;
 	else
Index: Test/51xtrace.ztst
===================================================================
@@ -2,6 +2,11 @@
 
 %prep
   mkdir xtrace.tmp && cd xtrace.tmp
+  function xtf {
+    local regression_test_dummy_variable
+    print "$*"
+  }
+  echo 'print "$*"' > xt.in
 
 %test
 
@@ -21,7 +26,11 @@
   repeat 1 do print 'Tracing: do builtin done'; done
   repeat 1 do print 'Tracing: do builtin done 2>file'; done 2>>xtrace.err
   repeat 1 do cat <<<'Tracing: do external done'; done
-  repeat 1 do cat <<<'Tracing: do external done'; done 2>>xtrace.err
+  repeat 1 do cat <<<'Tracing: do external done 2>file'; done 2>>xtrace.err
+  xtf 'Tracing: function'
+  xtf 'Tracing: function 2>file' 2>>xtrace.err
+  . ./xt.in 'Tracing: source'
+  . ./xt.in 'Tracing: source 2>file' 2>>xtrace.err
   set +x
   cat xtrace.err
 0:xtrace with and without redirection
@@ -40,7 +49,11 @@
 >Tracing: do builtin done
 >Tracing: do builtin done 2>file
 >Tracing: do external done
->Tracing: do external done
+>Tracing: do external done 2>file
+>Tracing: function
+>Tracing: function 2>file
+>Tracing: source
+>Tracing: source 2>file
 >+ZTST_execchunk:2> print Tracing: ( builtin ) 2>file
 >+ZTST_execchunk:2> cat
 >+ZTST_execchunk:2> print Tracing: { builtin } 2>file
@@ -57,4 +70,14 @@
 ?+ZTST_execchunk:2> cat
 ?+ZTST_execchunk:2> print Tracing: do builtin done
 ?+ZTST_execchunk:2> cat
+?+ZTST_execchunk:2> xtf Tracing: function
+?+xtf:0> local regression_test_dummy_variable
+?+xtf:0> print Tracing: function
+?+ZTST_execchunk:2> xtf Tracing: function 2>file
+?+xtf:0> local regression_test_dummy_variable
+?+xtf:0> print Tracing: function 2>file
+?+ZTST_execchunk:2> . ./xt.in Tracing: source
+?+./xt.in:1> print Tracing: source
+?+ZTST_execchunk:2> . ./xt.in Tracing: source 2>file
+?+./xt.in:1> print Tracing: source 2>file
 ?+ZTST_execchunk:2> set +x

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-03-15 17:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-15 17:36 PATCH: One last (?!?) tweak to xtrace redirection Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).