Make "set -e" once again provide the behavior documented in the man page,

which was unnecessarily changed in revision 1.50 while fixing other bugs.
That is, exit the shell if the last command in a || or && compound statement
is not short-circuited, and exits with a false status.  I.e., the following
will cause the shell to exit:

  set -e
  false || false

While this is not the prescribed behavior in SUSv3, it is what our man page
documents, and it is what all of the following implementations do:

  NetBSD /bin/ksh (pdksh)
  bash
  zsh
  Solaris 9 /bin/sh
  Solaris 9 /usr/xpg4/bin/sh
  Solaris 9 /usr/bin/ksh
  Tru64 /bin/sh
  HP/UX 11 /bin/sh

The "standard" seems to be wrong in this instance.
This commit is contained in:
mycroft 2004-06-30 09:32:38 +00:00
parent 313b9c84ab
commit 1ccdf5daeb

View File

@ -1,4 +1,4 @@
/* $NetBSD: eval.c,v 1.78 2004/06/26 22:09:49 dsl Exp $ */
/* $NetBSD: eval.c,v 1.79 2004/06/30 09:32:38 mycroft Exp $ */
/*-
* Copyright (c) 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
#else
__RCSID("$NetBSD: eval.c,v 1.78 2004/06/26 22:09:49 dsl Exp $");
__RCSID("$NetBSD: eval.c,v 1.79 2004/06/30 09:32:38 mycroft Exp $");
#endif
#endif /* not lint */
@ -237,13 +237,13 @@ evaltree(union node *n, int flags)
evaltree(n->nbinary.ch1, EV_TESTED);
if (evalskip || exitstatus != 0)
goto out;
evaltree(n->nbinary.ch2, flags | EV_TESTED);
evaltree(n->nbinary.ch2, flags);
break;
case NOR:
evaltree(n->nbinary.ch1, EV_TESTED);
if (evalskip || exitstatus == 0)
goto out;
evaltree(n->nbinary.ch2, flags | EV_TESTED);
evaltree(n->nbinary.ch2, flags);
break;
case NREDIR:
expredir(n->nredir.redirect);