summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorkre <kre@NetBSD.org>2019-05-04 02:52:22 +0000
committerkre <kre@NetBSD.org>2019-05-04 02:52:22 +0000
commite31d68842d5626f22ea5ce8b59267abc49bf51cc (patch)
tree1204447cf2d49d9ef0e51e77d7c396f64ea1b263 /bin
parent3f7956eda17f65c569dc50a954ccfb414673dbfb (diff)
Fix an (apparent) ancient ash bug, that was apparently fixed sometime
in the past, but managed to re-surface... The expression "${0+\}}" should expand to "}" not "\}" Almost all other shells handle it that way (incl FreeBSD & dash). Issue pointed out by Martijn Dekker. Add ATF sub-tests for the 4 old var expand operators (${var+word} ${var-word} ${var-word} and ${var?word} - including the forms with the ':' included) and amongst those tests include test cases for this issue, so if the bug tries to appear again, we can squash it quicker. (The newer pattern matching operators are already well tested as part of testing patterns.)
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/parser.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c
index e31d8ee7294..166138ce48e 100644
--- a/bin/sh/parser.c
+++ b/bin/sh/parser.c
@@ -1,4 +1,4 @@
-/* $NetBSD: parser.c,v 1.167 2019/02/27 04:10:56 kre Exp $ */
+/* $NetBSD: parser.c,v 1.168 2019/05/04 02:52:22 kre Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
#else
-__RCSID("$NetBSD: parser.c,v 1.167 2019/02/27 04:10:56 kre Exp $");
+__RCSID("$NetBSD: parser.c,v 1.168 2019/05/04 02:52:22 kre Exp $");
#endif
#endif /* not lint */
@@ -1974,6 +1974,7 @@ readtoken1(int firstc, char const *syn, int oneword)
CVTRACE(DBG_LEXER, quotef==0, (" QF=1 "));
quotef = 1; /* current token is quoted */
if (quoted && c != '\\' && c != '`' &&
+ (c != '}' || varnest == 0) &&
c != '$' && (c != '"' || magicq)) {
/*
* retain the \ (which we *know* needs CTLESC)