summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2010-04-03 20:35:39 +0000
committerjilles <jilles@FreeBSD.org>2010-04-03 20:35:39 +0000
commit840173ec99f4f9addaad9214d467479f35ab3997 (patch)
treebc6b451f3a58d70e94024be31b2c38899376a31d
parent11ba493dd73707d5b7b0aa9b43754267c1aa59c2 (diff)
downloadFreeBSD-src-840173ec99f4f9addaad9214d467479f35ab3997.zip
FreeBSD-src-840173ec99f4f9addaad9214d467479f35ab3997.tar.gz
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)
-rw-r--r--bin/sh/parser.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c
index e19a04e..3f3103a 100644
--- a/bin/sh/parser.c
+++ b/bin/sh/parser.c
@@ -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);
OpenPOWER on IntegriCloud