svn commit: r206942 - in stable/8: bin/sh
tools/regression/bin/sh/parser
Jilles Tjoelker
jilles at FreeBSD.org
Tue Apr 20 22:20:32 UTC 2010
Author: jilles
Date: Tue Apr 20 22:20:31 2010
New Revision: 206942
URL: http://svn.freebsd.org/changeset/base/206942
Log:
MFC r199282: sh: Allow a newline before "in" in a for command,
as required by POSIX.
Added:
stable/8/tools/regression/bin/sh/parser/for1.0
- copied unchanged from r199282, head/tools/regression/bin/sh/parser/for1.0
Modified:
stable/8/bin/sh/parser.c
Directory Properties:
stable/8/bin/sh/ (props changed)
stable/8/tools/regression/bin/sh/ (props changed)
Modified: stable/8/bin/sh/parser.c
==============================================================================
--- stable/8/bin/sh/parser.c Tue Apr 20 22:15:41 2010 (r206941)
+++ stable/8/bin/sh/parser.c Tue Apr 20 22:20:31 2010 (r206942)
@@ -365,7 +365,9 @@ TRACE(("expecting DO got %s %s\n", tokna
n1 = (union node *)stalloc(sizeof (struct nfor));
n1->type = NFOR;
n1->nfor.var = wordtext;
- if (readtoken() == TWORD && ! quoteflag && equal(wordtext, "in")) {
+ while (readtoken() == TNL)
+ ;
+ if (lasttoken == TWORD && ! quoteflag && equal(wordtext, "in")) {
app = ≈
while (readtoken() == TWORD) {
n2 = (union node *)stalloc(sizeof (struct narg));
Copied: stable/8/tools/regression/bin/sh/parser/for1.0 (from r199282, head/tools/regression/bin/sh/parser/for1.0)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ stable/8/tools/regression/bin/sh/parser/for1.0 Tue Apr 20 22:20:31 2010 (r206942, copy of r199282, head/tools/regression/bin/sh/parser/for1.0)
@@ -0,0 +1,29 @@
+# $FreeBSD$
+
+nl='
+'
+list=' a b c'
+for s1 in "$nl" " "; do
+ for s2 in "$nl" ";"; do
+ for s3 in "$nl" " "; do
+ r=''
+ eval "for i${s1}in ${list}${s2}do${s3}r=\"\$r \$i\"; done"
+ [ "$r" = "$list" ] || exit 1
+ done
+ done
+done
+set -- $list
+for s2 in "$nl" " " ";"; do # s2=";" is an extension to POSIX
+ for s3 in "$nl" " "; do
+ r=''
+ eval "for i${s2}do${s3}r=\"\$r \$i\"; done"
+ [ "$r" = "$list" ] || exit 1
+ done
+done
+for s1 in "$nl" " "; do
+ for s2 in "$nl" ";"; do
+ for s3 in "$nl" " "; do
+ eval "for i${s1}in${s2}do${s3}exit 1; done"
+ done
+ done
+done
More information about the svn-src-stable-8
mailing list