xref: /freebsd/contrib/bmake/unit-tests/make-exported.mk (revision 4fde40d9b540ea1a544cb4378a14f2f6da85ca6d)
1*4fde40d9SSimon J. Gerraty# $NetBSD: make-exported.mk,v 1.7 2022/09/09 18:36:15 sjg Exp $
22c3632d1SSimon J. Gerraty#
32c3632d1SSimon J. Gerraty# As of 2020-08-09, the code in Var_Export is shared between the .export
42c3632d1SSimon J. Gerraty# directive and the .MAKE.EXPORTED variable.  This leads to non-obvious
52c3632d1SSimon J. Gerraty# behavior for certain variable assignments.
62c3632d1SSimon J. Gerraty
7956e45f6SSimon J. Gerraty-env=		make-exported-value-env
8956e45f6SSimon J. Gerraty-literal=	make-exported-value-literal
92c3632d1SSimon J. GerratyUT_VAR=		${UNEXPANDED}
102c3632d1SSimon J. Gerraty
11956e45f6SSimon J. Gerraty# Before 2020-10-03, the following line took the code path of .export-env,
12956e45f6SSimon J. Gerraty# which was surprising behavior.  Since 2020-10-03 this line tries to
13956e45f6SSimon J. Gerraty# export the variable named "-env", but that is rejected because the
14956e45f6SSimon J. Gerraty# variable name starts with a hyphen.
15956e45f6SSimon J. Gerraty.MAKE.EXPORTED=		-env
16956e45f6SSimon J. Gerraty
17956e45f6SSimon J. Gerraty# Before 2020-10-03, if the value of .MAKE.EXPORTED started with "-literal",
18956e45f6SSimon J. Gerraty# make behaved like a mixture of .export-literal and a regular .export.
19956e45f6SSimon J. Gerraty#
20956e45f6SSimon J. Gerraty# Since 2020-10-03, the "variable" named "-literal" is not exported anymore,
21956e45f6SSimon J. Gerraty# it is just ignored since its name starts with '-'.
22956e45f6SSimon J. Gerraty.MAKE.EXPORTED=		-literal UT_VAR
232c3632d1SSimon J. Gerraty
242c3632d1SSimon J. Gerratyall:
25*4fde40d9SSimon J. Gerraty	@env | sort | ${EGREP} '^UT_|make-exported-value' || true
26