From owner-svn-src-head@FreeBSD.ORG Sat Nov 14 22:08:32 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E319D1065694; Sat, 14 Nov 2009 22:08:32 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CF3A78FC1D; Sat, 14 Nov 2009 22:08:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nAEM8W3q014783; Sat, 14 Nov 2009 22:08:32 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nAEM8Wh5014782; Sat, 14 Nov 2009 22:08:32 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <200911142208.nAEM8Wh5014782@svn.freebsd.org> From: Jilles Tjoelker Date: Sat, 14 Nov 2009 22:08:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r199282 - in head: bin/sh tools/regression/bin/sh/parser X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Nov 2009 22:08:33 -0000 Author: jilles Date: Sat Nov 14 22:08:32 2009 New Revision: 199282 URL: http://svn.freebsd.org/changeset/base/199282 Log: sh: Allow a newline before "in" in a for command, as required by POSIX. Added: head/tools/regression/bin/sh/parser/for1.0 (contents, props changed) Modified: head/bin/sh/parser.c Modified: head/bin/sh/parser.c ============================================================================== --- head/bin/sh/parser.c Sat Nov 14 20:30:42 2009 (r199281) +++ head/bin/sh/parser.c Sat Nov 14 22:08:32 2009 (r199282) @@ -364,7 +364,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)); Added: head/tools/regression/bin/sh/parser/for1.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/parser/for1.0 Sat Nov 14 22:08:32 2009 (r199282) @@ -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