summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-03-16 00:42:50 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-03-16 00:42:50 +0000
commitf85d4b147d226e061375c642a746a110babb50a6 (patch)
treecb7618fb1377bd78e20b8ebc180b39f780cbc84d
parentzsh-workers/10149 (diff)
downloadzsh-f85d4b147d226e061375c642a746a110babb50a6.tar
zsh-f85d4b147d226e061375c642a746a110babb50a6.tar.gz
zsh-f85d4b147d226e061375c642a746a110babb50a6.tar.bz2
zsh-f85d4b147d226e061375c642a746a110babb50a6.tar.lz
zsh-f85d4b147d226e061375c642a746a110babb50a6.tar.xz
zsh-f85d4b147d226e061375c642a746a110babb50a6.tar.zst
zsh-f85d4b147d226e061375c642a746a110babb50a6.zip
zsh-workers/10150
-rw-r--r--Src/exec.c3
-rw-r--r--Test/51xtrace.ztst27
2 files changed, 27 insertions, 3 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 9a8e7cd5d..3cf38d68c 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2012,7 +2012,8 @@ execcmd(Estate state, int input, int output, int how, int last1)
/* 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
diff --git a/Test/51xtrace.ztst b/Test/51xtrace.ztst
index 5dac18ff6..896ef09c7 100644
--- a/Test/51xtrace.ztst
+++ b/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