Author: jilles
Date: Fri Oct 29 21:06:57 2010
New Revision: 214531
URL: http://svn.freebsd.org/changeset/base/214531

Log:
  sh: Detect various additional errors in the parser.
  
  Apart from detecting breakage earlier or at all, this also fixes a segfault
  in the testsuite. The "handling" of the breakage left an invalid internal
  representation in some cases.
  
  Examples:
    echo a; do echo b
    echo `) echo a`
    echo `date; do do do`
  
  Exp-run done by:      pav (with some other sh(1) changes)

Added:
  head/tools/regression/bin/sh/errors/bad-keyword1.0   (contents, props changed)
Modified:
  head/bin/sh/parser.c

Modified: head/bin/sh/parser.c
==============================================================================
--- head/bin/sh/parser.c        Fri Oct 29 21:03:59 2010        (r214530)
+++ head/bin/sh/parser.c        Fri Oct 29 21:06:57 2010        (r214531)
@@ -220,7 +220,7 @@ parsecmd(int interact)
        if (t == TNL)
                return NULL;
        tokpushback++;
-       return list(1, 0);
+       return list(1, 1);
 }
 
 
@@ -231,7 +231,7 @@ list(int nlflag, int erflag)
        int tok;
 
        checkkwd = 2;
-       if (nlflag == 0 && tokendlist[peektoken()])
+       if (!nlflag && !erflag && tokendlist[peektoken()])
                return NULL;
        n1 = NULL;
        for (;;) {
@@ -277,7 +277,7 @@ list(int nlflag, int erflag)
                                tokpushback++;
                        }
                        checkkwd = 2;
-                       if (tokendlist[peektoken()])
+                       if (!nlflag && !erflag && tokendlist[peektoken()])
                                return n1;
                        break;
                case TEOF:

Added: head/tools/regression/bin/sh/errors/bad-keyword1.0
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/errors/bad-keyword1.0  Fri Oct 29 21:06:57 
2010        (r214531)
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+echo ':; fi' | sh -n 2>/dev/null && exit 1
+exit 0
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to