NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/53201: /bin/sh syntax error for ${var-xyz} with literal \n in xyz



>Number:         53201
>Category:       bin
>Synopsis:       /bin/sh syntax error for ${var-xyz} with literal \n in xyz
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Apr 21 21:25:00 +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@localhost:/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.)



Home | Main Index | Thread Index | Old Index