Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/ksh Bring in pdksh-5.2.14-patches.2.



details:   https://anonhg.NetBSD.org/src/rev/ae332e6f467f
branches:  trunk
changeset: 515603:ae332e6f467f
user:      wiz <wiz%NetBSD.org@localhost>
date:      Sat Sep 29 15:05:47 2001 +0000

description:
Bring in pdksh-5.2.14-patches.2.
ChangeLog entry:
Mon Jan 29 10:12:31 NST 2001 Michael Rendell (michael%garfield.cs.mun.ca@localhost)
* c_exec.c(execute): added rv_prop flag to prevent if/while/for/...
  in the presence of "set -e" from causing the shell to exit.
Example:
        set -e
        (false && echo hi)
[exits shell though it shouldn't]
ChangeLog and example provided by pdksh maintainer, Michael Rendell.

diffstat:

 bin/ksh/exec.c |  14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diffs (95 lines):

diff -r fc69de9ab5db -r ae332e6f467f bin/ksh/exec.c
--- a/bin/ksh/exec.c    Sat Sep 29 14:23:37 2001 +0000
+++ b/bin/ksh/exec.c    Sat Sep 29 15:05:47 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exec.c,v 1.5 1999/10/20 15:09:59 hubertf Exp $ */
+/*     $NetBSD: exec.c,v 1.6 2001/09/29 15:05:47 wiz Exp $     */
 
 /*
  * execute command tree
@@ -78,6 +78,7 @@
 {
        int i;
        volatile int rv = 0;
+       volatile int rv_prop = 0; /* rv being propogated or newly generated? */
        int pv[2];
        char ** volatile ap;
        char *s, *cp;
@@ -159,6 +160,7 @@
 
          case TPAREN:
                rv = execute(t->left, flags|XFORK);
+               rv_prop = 1;
                break;
 
          case TPIPE:
@@ -277,6 +279,7 @@
                        rv = execute(t->right, flags & XERROK);
                else
                        flags |= XERROK;
+               rv_prop = 1;
                break;
 
          case TBANG:
@@ -325,6 +328,7 @@
                        }
                }
                rv = 0; /* in case of a continue */
+               rv_prop = 1;
                if (t->type == TFOR) {
                        while (*ap != NULL) {
                                setstr(global(t->str), *ap++, KSH_UNWIND_ERROR);
@@ -336,6 +340,7 @@
                        for (;;) {
                                if (!(cp = do_selectargs(ap, is_first))) {
                                        rv = 1;
+                                       rv_prop = 0;
                                        break;
                                }
                                is_first = FALSE;
@@ -367,6 +372,7 @@
                rv = 0; /* in case of a continue */
                while ((execute(t->left, XERROK) == 0) == (t->type == TWHILE))
                        rv = execute(t->right, flags & XERROK);
+               rv_prop = 1;
                break;
 
          case TIF:
@@ -376,6 +382,7 @@
                rv = execute(t->left, XERROK) == 0 ?
                        execute(t->right->left, flags & XERROK) :
                        execute(t->right->right, flags & XERROK);
+               rv_prop = 1;
                break;
 
          case TCASE:
@@ -388,10 +395,12 @@
                break;
          Found:
                rv = execute(t->left, flags & XERROK);
+               rv_prop = 1;
                break;
 
          case TBRACE:
                rv = execute(t->left, flags & XERROK);
+               rv_prop = 1;
                break;
 
          case TFUNCT:
@@ -403,6 +412,7 @@
                 * (allows "ls -l | time grep foo").
                 */
                rv = timex(t, flags & ~XEXEC);
+               rv_prop = 1;
                break;
 
          case TEXEC:           /* an eval'd TCOM */
@@ -432,7 +442,7 @@
                unwind(LEXIT);  /* exit child */
                /* NOTREACHED */
        }
-       if (rv != 0 && !(flags & XERROK)) {
+       if (rv != 0 && !rv_prop && !(flags & XERROK)) {
                if (Flag(FERREXIT))
                        unwind(LERROR);
                trapsig(SIGERR_);



Home | Main Index | Thread Index | Old Index