varname-empty.mk revision 1.2
11.2Srillig# $NetBSD: varname-empty.mk,v 1.2 2020/08/22 20:31:50 rillig Exp $
21.1Srillig#
31.1Srillig# Tests for the special variable with the empty name.
41.1Srillig#
51.1Srillig# The variable "" is not supposed to be assigned any value.
61.1Srillig# This is because it is heavily used in the .for loop expansion,
71.1Srillig# as well as to generate arbitrary strings, as in ${:Ufallback}.
81.1Srillig
91.2Srillig# Until 2020-08-22 it was possible to assign a value to the variable with
101.2Srillig# the empty name, leading to all kinds of unexpected effects.
111.1Srillig!=	echo 'value'
121.1Srillig
131.1Srillig# The .for loop expands the expression ${i} to ${:U1}, ${:U2} and so on.
141.1Srillig# This only works if the variable with the empty name is guaranteed to
151.1Srillig# be undefined.
161.1Srillig.for i in 1 2 3
171.1SrilligNUMBERS+=	${i}
181.1Srillig.endfor
191.1Srillig
201.1Srilligall:
211.1Srillig	@echo ${:Ufallback}
221.1Srillig	@echo ${NUMBERS}
23