NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/50827: sh -c ': "${x=$((1))}"' gives bogus syntax error
The following reply was made to PR bin/50827; it has been noted by GNATS.
From: Robert Elz <kre%munnari.OZ.AU@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: bin/50827: sh -c ': "${x=$((1))}"' gives bogus syntax error
Date: Fri, 19 Feb 2016 16:31:13 +0700
Date: Thu, 18 Feb 2016 07:35:00 +0000 (UTC)
From: rhansen%rhansen.org@localhost
Message-ID: <20160218073500.BFF977ACD0%mollari.NetBSD.org@localhost>
| /bin/sh incorrectly reports a syntax error ("Missing '}'") with the following line:
|
| : "${x=$((1))}"
It also mishandles ...
sh -c ': ${x="$(("1"))"}'
sh: Syntax error: Missing '))'
and similar cases.
I believe the following patch might fix both of those problems (the 4
lines deleted fix rhansen's problem, the extra manipulation of varnest
and associated code fixes the $(( )) case.)
These bugs have been there a long time, so once verified, the fix should
be pulled up to the netbsd 6 & netbsd 7 series (all variants.)
kre
--- parser.c.old 2014-08-30 06:38:31.000000000 +0700
+++ parser.c 2016-02-19 16:18:50.000000000 +0700
@@ -1106,13 +1106,11 @@
--parenlevel;
} else {
if (pgetc() == ')') {
+ if (varnest > 0) /*always*/
+ varnest--;
if (--arinest == 0) {
USTPUTC(CTLENDARI, out);
syntax = prevsyntax;
- if (syntax == DQSYNTAX)
- SETDBLQUOTE();
- else
- CLRDBLQUOTE();
} else
USTPUTC(')', out);
} else {
@@ -1562,6 +1560,13 @@
*/
USTPUTC('(', out);
}
+
+ varnest++;
+ if (varnest >= maxnest) {
+ dblquotep = ckrealloc(dblquotep, maxnest / 8);
+ dblquotep[(maxnest / 32) - 1] = 0;
+ maxnest += 32;
+ }
goto parsearith_return;
}
Home |
Main Index |
Thread Index |
Old Index