Fix for -n flag. Contine execution for some `special' builtins
authorChristos Zoulas <christos@ucbvax.Berkeley.EDU>
Wed, 4 Sep 1991 16:37:26 +0000 (08:37 -0800)
committerChristos Zoulas <christos@ucbvax.Berkeley.EDU>
Wed, 4 Sep 1991 16:37:26 +0000 (08:37 -0800)
SCCS-vsn: bin/csh/sem.c 5.20

usr/src/bin/csh/sem.c

index 64235e4..315faf7 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)sem.c      5.19 (Berkeley) %G%";
+static char sccsid[] = "@(#)sem.c      5.20 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -76,8 +76,6 @@ execute(t, wanttty, pipein, pipeout)
            if (noexec)
                (void) close(0);
        }
            if (noexec)
                (void) close(0);
        }
-       if (noexec)
-           break;
 
        set(STRstatus, Strsave(STR0));
 
 
        set(STRstatus, Strsave(STR0));
 
@@ -124,15 +122,29 @@ execute(t, wanttty, pipein, pipeout)
            else
                break;
 
            else
                break;
 
-       /* is t a command */
+       /* is it a command */
        if (t->t_dtyp == NODE_COMMAND) {
            /*
             * Check if we have a builtin function and remember which one.
             */
            bifunc = isbfunc(t);
        if (t->t_dtyp == NODE_COMMAND) {
            /*
             * Check if we have a builtin function and remember which one.
             */
            bifunc = isbfunc(t);
+           if (noexec) {
+               /*
+                * Continue for builtins that are part of the scripting language
+                */
+               if (bifunc->bfunct != dobreak   && bifunc->bfunct != docontin &&
+                   bifunc->bfunct != doelse    && bifunc->bfunct != doend    &&
+                   bifunc->bfunct != doforeach && bifunc->bfunct != dogoto   &&
+                   bifunc->bfunct != doif      && bifunc->bfunct != dorepeat &&
+                   bifunc->bfunct != doswbrk   && bifunc->bfunct != doswitch &&
+                   bifunc->bfunct != dowhile   && bifunc->bfunct != dozip)
+                   break;
+           }
        }
        else {                  /* not a command */
            bifunc = NULL;
        }
        else {                  /* not a command */
            bifunc = NULL;
+           if (noexec)
+               break;
        }
 
        /*
        }
 
        /*