1 # $NetBSD: varname.mk,v 1.8 2020/11/02 22:59:48 rillig Exp $
3 # Tests for special variables, such as .MAKE or .PARSEDIR.
4 # And for variable names in general.
8 # In variable names, braces are allowed, but they must be balanced.
9 # Parentheses and braces may be mixed.
11 .if "${VAR{{{}}}}" != "3 braces"
15 # In variable expressions, the parser works differently. It doesn't treat
16 # braces and parentheses equally, therefore the first closing brace already
17 # marks the end of the variable name.
19 ${VARNAME}= 3 open parentheses
20 .if "${VAR(((}}}}" != "3 open parentheses}}}"
24 # In the above test, the variable name is constructed indirectly. Neither
25 # of the following expressions produces the intended effect.
27 # This is not a variable assignment since the parentheses and braces are not
28 # balanced. At the end of the line, there are still 3 levels open, which
29 # means the variable name is not finished.
31 # On the left-hand side of a variable assignments, the backslash is not parsed
32 # as an escape character, therefore the parentheses still count to the nesting
33 # level, which at the end of the line is still 3. Therefore this is not a
34 # variable assignment as well.
36 # To assign to a variable with an arbitrary name, the variable name has to
37 # come from an external source, not the text that is parsed in the assignment
38 # itself. This is exactly the reason why further above, the indirect
39 # ${VARNAME} works, while all other attempts fail.