sh: Treat unexpected newlines in substitutions as a syntax error.

The old approach was wrong because PS2 was not used and seems unlikely to
parse extensions (ksh93's ${ COMMAND} may well fail to parse).

Exp-run done by: erwin (with some other sh(1) changes)
This commit is contained in:
Jilles Tjoelker 2010-04-03 20:35:39 +00:00
parent cc4b8e985d
commit d323650f14
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=206144

View File

@ -1401,6 +1401,8 @@ parsesub: {
subtype = VSERROR;
if (c == '}')
pungetc();
else if (c == '\n' || c == PEOF)
synerror("Unexpected end of line in substitution");
else
USTPUTC(c, out);
} else {
@ -1417,6 +1419,8 @@ parsesub: {
default:
p = strchr(types, c);
if (p == NULL) {
if (c == '\n' || c == PEOF)
synerror("Unexpected end of line in substitution");
if (flags == VSNUL)
STPUTC(':', out);
STPUTC(c, out);