Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Problems with the functions[] parameter (not; but other issues)
- X-seq: zsh-workers 10071
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: Problems with the functions[] parameter (not; but other issues)
- Date: Sat, 11 Mar 2000 18:14:29 +0000
- In-reply-to: <200003101245.NAA03786@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <200003101245.NAA03786@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author