From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>,
zsh-workers@sunsite.auc.dk
Subject: Re: Problems with the functions[] parameter (not; but other issues)
Date: Sat, 11 Mar 2000 18:14:29 +0000 [thread overview]
Message-ID: <1000311181429.ZM26382@candle.brasslantern.com> (raw)
In-Reply-To: <200003101245.NAA03786@beta.informatik.hu-berlin.de>
On Mar 10, 1:45pm, Sven Wischnowsky wrote:
} Subject: Re: Problems with the functions[] parameter (not; but other issue
}
} Bart Schaefer wrote:
} > (2) Redirecting stderr of a function is a bit inconsistent with respect
} > to xtrace. Zsh presently works the same way bash does, which means
} > the xtrace output of shell functions is *not* redirected along with
} > their stderr. This is not the same as e.g. `do'-loops and { ... }.
}
} What really irritated me here (and it still looks wrong): add
}
} set -x
} _call version diff -v </dev/null 2>/dev/null
} set +x
}
} Only the `first' line of _call is shown, xtrace output stops when
} zstyle is called.
Yes, I saw that too. Improper restoration of xtrerr. Patch below.
} Or maybe my exec.c is out-of date, because:
}
} > And (2) in turn leads me to notice a third thing:
} >
} > In bash, redirecting the standard error of the `.' command redirects
} > the xtrace output from the commands in the sourced file. This doesn't
} > presently happen in zsh, but I think the zsh behavior is more useful;
} > other opinions? Is compatibility more important? What does ksh do?
}
} if I do `. ./foo 2> bar' I get the xtrace output of the commands in
} `foo' in `bar'. Same as for the ksh I have here, btw.
The patch below may change this -- the behavior I previously saw for `.'
was the same as what you described for `_call' -- that is, the first line
of ./foo would xtrace to the (old) stderr, and then everything else would
be redirected to `bar', because xtrerr was getting reset too soon.
The patch below leaves `.' behaving like functions do. If we want `.'
(and `source') to act like a shell construct instead (for bash and ksh
compatibility if nothing else) then we'll have to set xtrerr back to
stderr (temporarily) in either builtin.c:bin_dot() or init.c:source().
Index: Src/exec.c
===================================================================
@@ -1608,6 +1608,7 @@
LinkList redir;
wordcode code;
Wordcode beg = state->pc, varspc;
+ FILE *oxtrerr = xtrerr;
doneps4 = 0;
redir = (wc_code(*state->pc) == WC_REDIR ? ecgetredirs(state) : NULL);
@@ -2317,10 +2318,10 @@
fixfds(save);
done:
- if (xtrerr != stderr) {
+ if (xtrerr != oxtrerr) {
fil = fileno(xtrerr);
fclose(xtrerr);
- xtrerr = stderr;
+ xtrerr = oxtrerr;
zclose(fil);
}
}
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
next prev parent reply other threads:[~2000-03-11 18:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-03-10 12:45 Sven Wischnowsky
2000-03-11 18:14 ` Bart Schaefer [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-03-10 9:49 Problems with the functions[] parameter Sven Wischnowsky
2000-03-10 12:03 ` Problems with the functions[] parameter (not; but other issues) Bart Schaefer
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=1000311181429.ZM26382@candle.brasslantern.com \
--to=schaefer@candle.brasslantern.com \
--cc=wischnow@informatik.hu-berlin.de \
--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).