From owner-svn-src-head@freebsd.org Sun May 20 17:25:54 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D6558EE7945; Sun, 20 May 2018 17:25:53 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 871A78702E; Sun, 20 May 2018 17:25:53 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 685FF19579; Sun, 20 May 2018 17:25:53 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4KHPrIQ059292; Sun, 20 May 2018 17:25:53 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4KHPqje059288; Sun, 20 May 2018 17:25:52 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201805201725.w4KHPqje059288@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sun, 20 May 2018 17:25:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333927 - in head/bin/sh: . tests/expansion X-SVN-Group: head X-SVN-Commit-Author: jilles X-SVN-Commit-Paths: in head/bin/sh: . tests/expansion X-SVN-Commit-Revision: 333927 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 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: Sun, 20 May 2018 17:25:54 -0000 Author: jilles Date: Sun May 20 17:25:52 2018 New Revision: 333927 URL: https://svnweb.freebsd.org/changeset/base/333927 Log: sh: Allow unquoted newlines in word in ${param+word} etc. POSIX requires accepting unquoted newlines in word in parameter expansions like ${param+word}, ${param#word}, although the Bourne shell did not support it, it is not commonly used and might make it harder to find a missing closing brace. It was also strange that something like foo="${bar# }" was rejected. Reported by: Martijn Dekker via Robert Elz Added: head/bin/sh/tests/expansion/plus-minus9.0 (contents, props changed) head/bin/sh/tests/expansion/trim10.0 (contents, props changed) head/bin/sh/tests/expansion/trim11.0 (contents, props changed) Modified: head/bin/sh/parser.c head/bin/sh/tests/expansion/Makefile Modified: head/bin/sh/parser.c ============================================================================== --- head/bin/sh/parser.c Sun May 20 16:03:21 2018 (r333926) +++ head/bin/sh/parser.c Sun May 20 17:25:52 2018 (r333927) @@ -1434,7 +1434,8 @@ readtoken1(int firstc, char const *initialsyntax, cons switch(synentry) { case CNL: /* '\n' */ - if (state[level].syntax == BASESYNTAX) + if (level == 0 && + state[level].syntax == BASESYNTAX) goto endword; /* exit outer loop */ USTPUTC(c, out); plinno++; Modified: head/bin/sh/tests/expansion/Makefile ============================================================================== --- head/bin/sh/tests/expansion/Makefile Sun May 20 16:03:21 2018 (r333926) +++ head/bin/sh/tests/expansion/Makefile Sun May 20 17:25:52 2018 (r333927) @@ -84,6 +84,7 @@ ${PACKAGE}FILES+= plus-minus5.0 ${PACKAGE}FILES+= plus-minus6.0 ${PACKAGE}FILES+= plus-minus7.0 ${PACKAGE}FILES+= plus-minus8.0 +${PACKAGE}FILES+= plus-minus9.0 ${PACKAGE}FILES+= question1.0 ${PACKAGE}FILES+= readonly1.0 ${PACKAGE}FILES+= redir1.0 @@ -101,5 +102,7 @@ ${PACKAGE}FILES+= trim6.0 ${PACKAGE}FILES+= trim7.0 ${PACKAGE}FILES+= trim8.0 ${PACKAGE}FILES+= trim9.0 +${PACKAGE}FILES+= trim10.0 +${PACKAGE}FILES+= trim11.0 .include Added: head/bin/sh/tests/expansion/plus-minus9.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/expansion/plus-minus9.0 Sun May 20 17:25:52 2018 (r333927) @@ -0,0 +1,8 @@ +# $FreeBSD$ + +a=1 +b=${a+ +} +n=' +' +[ "$b" = "$n" ] Added: head/bin/sh/tests/expansion/trim10.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/expansion/trim10.0 Sun May 20 17:25:52 2018 (r333927) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +a='z +' +b=${a% +} +[ "$b" = z ] Added: head/bin/sh/tests/expansion/trim11.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/expansion/trim11.0 Sun May 20 17:25:52 2018 (r333927) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +a='z +' +b="${a% +}" +[ "$b" = z ]