From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: One last (?!?) tweak to xtrace redirection
Date: Wed, 15 Mar 2000 17:36:36 +0000 [thread overview]
Message-ID: <1000315173636.ZM23462@candle.brasslantern.com> (raw)
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
reply other threads:[~2000-03-15 17:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1000315173636.ZM23462@candle.brasslantern.com \
--to=schaefer@candle.brasslantern.com \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).