Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Oct 2010 21:06:58 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r214531 - in head: bin/sh tools/regression/bin/sh/errors
Message-ID:  <201010292106.o9TL6wtU057580@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010292106.o9TL6wtU057580>