varname-empty.mk revision 1.3
11.3Srillig# $NetBSD: varname-empty.mk,v 1.3 2020/08/22 21:02:56 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.3Srillig?= default 121.3Srillig#= assigned # XXX: probably undefined behavior 131.3Srillig+= appended 141.3Srillig:= subst 151.1Srillig!= echo 'value' 161.1Srillig 171.1Srillig# The .for loop expands the expression ${i} to ${:U1}, ${:U2} and so on. 181.1Srillig# This only works if the variable with the empty name is guaranteed to 191.1Srillig# be undefined. 201.1Srillig.for i in 1 2 3 211.1SrilligNUMBERS+= ${i} 221.1Srillig.endfor 231.1Srillig 241.1Srilligall: 251.1Srillig @echo ${:Ufallback} 261.1Srillig @echo ${NUMBERS} 27