freebsd-nq/contrib/bmake/unit-tests/varname-dollar.mk
Simon J. Gerraty 2c3632d14f Update to bmake-20200902
Lots of code refactoring, simplification and cleanup.
Lots of new unit-tests providing much higher code coverage.
All courtesy of rillig at netbsd.

Other significant changes:

o new read-only variable .SHELL which provides the path of the shell
  used to run scripts (as defined by  the .SHELL target).

o variable parsing detects more errors.

o new debug option -dl: LINT mode, does the equivalent of := for all
  variable assignments so that file and line number are reported for
  variable parse errors.
2020-09-05 19:29:42 +00:00

30 lines
1020 B
Makefile

# $NetBSD: varname-dollar.mk,v 1.3 2020/08/19 05:40:06 rillig Exp $
#
# Tests for the expression "$$", which looks as if it referred to a variable,
# but simply expands to a single '$' sign.
#
# If there really were a special variable named '$', the expressions ${${DOLLAR}}
# and $$ would always expand to the same value.
# Using the dollar sign in variable names is tricky and not recommended.
# To see that using this variable indeed affects the variable '$', run the
# test individually with the -dv option.
DOLLAR= $$
# At this point, the variable '$' is not defined. Therefore the second line
# returns an empty string.
.info dollar is $$.
.info dollar in braces is ${${DOLLAR}}.
# Now overwrite the '$' variable to see whether '$$' really expands to that
# variable, or whether '$$' is handled by the parser.
${DOLLAR}= dollar
# At this point, the variable '$' is defined, therefore its value is printed
# in the second .info directive.
.info dollar is $$.
.info dollar in braces is ${${DOLLAR}}.
all:
@:;