tech-toolchain archive

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

Re: make: empty expansion if mixing round and curly braces



On Wed, May 08, 2019 at 01:35:22PM +0200, Edgar Fu? wrote:
 > > It's a "feature":
 > That's what I expected.
 > 
 > > BRACE=}
 > > VAR$(BRACE)=plop
 > > 
 > > foo:
 > > 	echo $(VAR})
 > What's the point/reason I can't write
 > 	VAR}=plop
 > while I don't need to write
 > 	echo $(VAR$(BRACE))
 > ?

Because the line parser (the code that figures out whether a line is a
variable assignment, rule, or recipe line) is more robust than some of
the other bits and rejects (some) things it doesn't understand.

The long-term solution to this problem is to rework the whole parser
(this is already on the agenda but it's nontrivial) -- right now make
works by scanning and rescanning strings for variables over and over
again, which causes assorted problems, and trying to adjust all the
places where it tries to do parens and braces matching without causing
worse problems is a fairly ticklish job.

Anyway, don't write anything that _relies_ on this behavior as
hopefully it will cease to work sometime.

In the meantime I don't think there's a good way to not be tripped up
by the typo. :-(

 > > I'm not sure what make thinks the variable name is if you leave off
 > > the close-paren entirely, but I'm sure it's *something* and if you can
 > > figure out what you can give that variable a value
 >
 > I tried both -dv and -dp to no avail.

One would have to wade into the source, but unfortunately it's kind of
a maze...

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index