xref: /freebsd/contrib/bmake/unit-tests/varname-dollar.mk (revision faf25f48d601ae39f5752602f3020e2e92605625)
1# $NetBSD: varname-dollar.mk,v 1.3 2020/08/19 05:40:06 rillig Exp $
2#
3# Tests for the expression "$$", which looks as if it referred to a variable,
4# but simply expands to a single '$' sign.
5#
6# If there really were a special variable named '$', the expressions ${${DOLLAR}}
7# and $$ would always expand to the same value.
8
9# Using the dollar sign in variable names is tricky and not recommended.
10# To see that using this variable indeed affects the variable '$', run the
11# test individually with the -dv option.
12DOLLAR=		$$
13
14# At this point, the variable '$' is not defined. Therefore the second line
15# returns an empty string.
16.info dollar is $$.
17.info dollar in braces is ${${DOLLAR}}.
18
19# Now overwrite the '$' variable to see whether '$$' really expands to that
20# variable, or whether '$$' is handled by the parser.
21${DOLLAR}=	dollar
22
23# At this point, the variable '$' is defined, therefore its value is printed
24# in the second .info directive.
25.info dollar is $$.
26.info dollar in braces is ${${DOLLAR}}.
27
28all:
29	@:;
30