Date: Tue, 20 Apr 2010 22:20:31 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r206942 - in stable/8: bin/sh tools/regression/bin/sh/parser Message-ID: <201004202220.o3KMKWBt061708@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004202220.o3KMKWBt061708>