Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: sh compatibility issue
On Tue, 22 Feb 2011 17:51:18 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Tuesday, February 22, 2011, Vincent Stemen <vince.lists@xxxxxxxxxxx> wrote:
> >
> > I don't think it worked. With this patch added, the bahaviour did not
> > change from the previous patch. Fatal error in sh mode not not in zsh
> > mode.
>
> That's intentional. Zsh is not a POSIX shell unless you tell it to
> be, so in zsh mode it behaves the way zsh always has.
>
> As I understand it, the patch should change the behavior of other
> special builtins (in addition to exec), but only when POSIXBUILTINS is
> set.
Bart's right, sorry, I wasn't clear enough. Yes, this is the
long-standing policy.
If we'd been designing zsh from scratch now, there would be no point in
all these small areas where it's a bit different from POSIX by accident
rather than design. As it is, given the shell's manifold differences in
native mode, there's no point squeezing extra POSIX-compliance out of
native mode at the expense of backward compatibility.
By the way, one small tweak which should be rarely visible: now I've
upped the ante, there may be cases where we're forked at the point we
need to exit.
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.190
diff -p -u -r1.190 exec.c
--- Src/exec.c 22 Feb 2011 20:09:20 -0000 1.190
+++ Src/exec.c 23 Feb 2011 09:21:32 -0000
@@ -3306,8 +3306,10 @@ execcmd(Estate state, int input, int out
*/
if (redir_err || errflag) {
if (!isset(INTERACTIVE)) {
- /* We've already _exit'ed if forked */
- exit(1);
+ if (forked)
+ _exit(1);
+ else
+ exit(1);
}
errflag = 1;
}
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author