tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: make(1): is this a bug or PEBKAC?
Thank you for the quick and very helpful response!
>> 121 $(x:C;^.*\.([0-9].*)$$;$(INSTMANDIR)/cat\1;):
>> So, I'm wondering, is this a bug in 9.1's make, or am I doing
>> something wrong here?
> TL;DR: There are several cases in which make silently ignores parse
> errors, such as '$$' in variable modifiers. In other cases, it has
> become stricter over time, or the accepted syntax just changed.
:-(
> The crucial part in your example is the '$$'.
Actually, they were initially single $s. I changed them in an attempt
to fix it after seeing the 9.1 manpage note that the pattern and
replacement were subject to variable expansion; I wasn't sure what a
trailing single $ would do, so I doubled it.
> In normal strings, '$$' is used to escape a '$'. But in variable
> modifiers such as ':C', '\$' is used instead to escape a '$'.
Hm, is that documented somewhere? The only place I see \$ in the 9.1
manpage is in an example in the description of :q.
> In netbsd-9:usr.bin/make/var.c, the parser looks at
> '$(x:...(...)$$)', trying to figure out which parentheses match, see
> the comment "Attempt to avoid ';' inside substitution patterns" in
> parse.c. In this case, the parser fails. It counts the '$(' as
> starting a subexpression, then ignores the following '(', and when it
> sees the first ')', it considers the expression completed, leaving
> the '$$)' for a syntax error.
I don't see $$) anywhere in my lie above - nor anywhere else in
local-prog, for that matter. I'd have to go read the code, because
your description doesn't seem to match the results I see.
> To avoid all these edge cases, you should rewrite your makefile:
> * In the ':C' modifier, replace '$$' with '$', as there is no need to
> double it.
Okay.
> * In dependency lines, avoid modifiers containing ';'.
So my use of ; as the delimiter character is confusing things? Okay, I
can change that.
> To make the makefile easier readable and at the same time avoiding
> line noise, you can use a multi-variable .for loop, which are
> available since 2000:
Maybe. I'd have to see if that's present in all the make versions I
care about. I use <local-prog> on more than just work machines....
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse%rodents-montreal.org@localhost
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
Home |
Main Index |
Thread Index |
Old Index