NetBSD Problem Report #53201

From kre@munnari.OZ.AU  Sat Apr 21 21:23:12 2018
Return-Path: <kre@munnari.OZ.AU>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id BF96D7A166
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 21 Apr 2018 21:23:12 +0000 (UTC)
Message-Id: <201804212122.w3LLMYuS022304@jinx.noi.kre.to>
Date: Sun, 22 Apr 2018 04:22:34 +0700 (+07)
From: kre@munnari.OZ.AU
To: gnats-bugs@NetBSD.org
Subject: /bin/sh syntax error for ${var-xyz} with literal \n in xyz
X-Send-Pr-Version: 3.95

>Number:         53201
>Category:       bin
>Synopsis:       /bin/sh syntax error for ${var-xyz} with literal \n in xyz
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    kre
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Apr 21 21:25:00 +0000 2018
>Closed-Date:    Sun May 06 12:12:59 +0000 2018
>Last-Modified:  Sun May 06 12:12:59 +0000 2018
>Originator:     Robert Elz
>Release:        NetBSD 8.99.14
>Organization:
>Environment:
System: NetBSD jinx.noi.kre.to 8.99.14 NetBSD 8.99.14 (GENERIC) #3: Fri Apr 13 15:19:55 ICT 2018 kre@onyx.coe.psu.ac.th:/usr/obj/testing/amd64/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
	Currently (and from time immemorial) /bin/sh does:

	[jinx]$ var-${anything-abc
	sh: 1: Syntax error: Missing '}'

	That's incorrect.   POSIX says (XCU 2.3 (Token Recognition for sh))
	rule 5:

		If the current character is an unquoted '$' or '`',
		the shell shall identify the start of any candidates
		for parameter expansion (Section 2.6.2) [...]

		The shell shall read sufficient input to determine the
		end of the unit to be expanded [...]

		The characters found from the beginning of the substitution
		to its end, allowing for any recursion necessary to recognize
		embedded constructs, shall be included unmodified in the
		result token, [...]


>How-To-Repeat:
	Just type the above to /bin/sh

	Compare with /bin/ksh bash yash zsh ...
	(These issue PS2 when the \n appears, then continue
	collecting the remainder of the ${} expression.)

	Other ash derived shells have the same problem

>Fix:
	Coming soon (it is a trivial change.)
	ATF tests to test for this will appear first (as soon as
	I get the PR number from this PR to refer to.)

>Release-Note:

>Audit-Trail:
From: "Robert Elz" <kre@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53201 CVS commit: src/tests/bin/sh
Date: Sat, 21 Apr 2018 21:28:35 +0000

 Module Name:	src
 Committed By:	kre
 Date:		Sat Apr 21 21:28:35 UTC 2018

 Modified Files:
 	src/tests/bin/sh: t_expand.sh

 Log Message:
 Add a test case for PR bin/53201

 Currently this test case will fail, a fix is coming soon (not worth
 marking this as an expected failure.)

 This test case and the initial bug report comes from
 Martijn Dekker's modernish (shell/test set).


 To generate a diff of this commit:
 cvs rdiff -u -r1.18 -r1.19 src/tests/bin/sh/t_expand.sh

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Robert Elz" <kre@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53201 CVS commit: src/bin/sh
Date: Sat, 21 Apr 2018 21:32:14 +0000

 Module Name:	src
 Committed By:	kre
 Date:		Sat Apr 21 21:32:14 UTC 2018

 Modified Files:
 	src/bin/sh: parser.c

 Log Message:
 PR bin/53201

 Don't synerr on
 	${var-anything
 	more}

 The newline in the middle of the var expansion is permitted.

 Bug reported by Martijn Dekker from his modernish tests.

 XXX pullup-8


 To generate a diff of this commit:
 cvs rdiff -u -r1.145 -r1.146 src/bin/sh/parser.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->needs-pullups
State-Changed-By: kre@NetBSD.org
State-Changed-When: Sat, 21 Apr 2018 21:35:23 +0000
State-Changed-Why:
After sufficient testing, needs a pullup to -8


Responsible-Changed-From-To: bin-bug-people->kre
Responsible-Changed-By: kre@NetBSD.org
Responsible-Changed-When: Sat, 21 Apr 2018 21:35:35 +0000
Responsible-Changed-Why:
I am looking into this PR


State-Changed-From-To: needs-pullups->pending-pullups
State-Changed-By: kre@NetBSD.org
State-Changed-When: Thu, 03 May 2018 19:12:07 +0000
State-Changed-Why:
pullup-8 #804


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53201 CVS commit: [netbsd-8] src/bin/sh
Date: Sun, 6 May 2018 09:32:57 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sun May  6 09:32:57 UTC 2018

 Modified Files:
 	src/bin/sh [netbsd-8]: parser.c

 Log Message:
 Pull up following revision(s) (requested by kre in ticket #804):

 	bin/sh/parser.c: revision 1.146

 PR bin/53201

 Don't synerr on
 	${var-anything
 	more}

 The newline in the middle of the var expansion is permitted.

 Bug reported by Martijn Dekker from his modernish tests.
 XXX pullup-8


 To generate a diff of this commit:
 cvs rdiff -u -r1.132.2.3 -r1.132.2.4 src/bin/sh/parser.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: kre@NetBSD.org
State-Changed-When: Sun, 06 May 2018 12:12:59 +0000
State-Changed-Why:
Pullups completed


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.