]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bmake/unit-tests/varname-empty.mk
Update to bmake-20200902
[FreeBSD/FreeBSD.git] / contrib / bmake / unit-tests / varname-empty.mk
1 # $NetBSD: varname-empty.mk,v 1.5 2020/08/22 21:22:24 rillig Exp $
2 #
3 # Tests for the special variable with the empty name.
4 #
5 # The variable "" is not supposed to be assigned any value.
6 # This is because it is heavily used in the .for loop expansion,
7 # as well as to generate arbitrary strings, as in ${:Ufallback}.
8
9 # Until 2020-08-22 it was possible to assign a value to the variable with
10 # the empty name, leading to all kinds of unexpected effects.
11 ?=      default
12 =       assigned        # undefined behavior until 2020-08-22
13 +=      appended
14 :=      subst
15 !=      echo 'shell-output'
16
17 # The .for loop expands the expression ${i} to ${:U1}, ${:U2} and so on.
18 # This only works if the variable with the empty name is guaranteed to
19 # be undefined.
20 .for i in 1 2 3
21 NUMBERS+=       ${i}
22 .endfor
23
24 all:
25         @echo out: ${:Ufallback}
26         @echo out: ${NUMBERS}