From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22931 invoked from network); 11 Mar 2000 18:14:53 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 11 Mar 2000 18:14:53 -0000 Received: (qmail 17726 invoked by alias); 11 Mar 2000 18:14:45 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10071 Received: (qmail 17709 invoked from network); 11 Mar 2000 18:14:44 -0000 From: "Bart Schaefer" Message-Id: <1000311181429.ZM26382@candle.brasslantern.com> Date: Sat, 11 Mar 2000 18:14:29 +0000 In-Reply-To: <200003101245.NAA03786@beta.informatik.hu-berlin.de> Comments: In reply to Sven Wischnowsky "Re: Problems with the functions[] parameter (not; but other issues)" (Mar 10, 1:45pm) References: <200003101245.NAA03786@beta.informatik.hu-berlin.de> X-Mailer: Z-Mail (5.0.0 30July97) To: Sven Wischnowsky , zsh-workers@sunsite.auc.dk Subject: Re: Problems with the functions[] parameter (not; but other issues) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 } 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