1*8d5c8e21SSimon J. Gerraty# $NetBSD: directive-export-literal.mk,v 1.8 2024/06/01 18:44:05 rillig Exp $ 22c3632d1SSimon J. Gerraty# 3956e45f6SSimon J. Gerraty# Tests for the .export-literal directive, which exports a variable value 4956e45f6SSimon J. Gerraty# without expanding it. 52c3632d1SSimon J. Gerraty 6956e45f6SSimon J. GerratyUT_VAR= value with ${UNEXPANDED} expression 7956e45f6SSimon J. Gerraty 8956e45f6SSimon J. Gerraty.export-literal UT_VAR 92c3632d1SSimon J. Gerraty 10e2eeea75SSimon J. Gerraty.export-literal # oops: missing argument 11e2eeea75SSimon J. Gerraty 12*8d5c8e21SSimon J. Gerraty# After a variable whose value does not contain a '$' is exported, a following 13*8d5c8e21SSimon J. Gerraty# .export-literal can be skipped, to avoid a setenv call, which may leak 14*8d5c8e21SSimon J. Gerraty# memory on some platforms. 15*8d5c8e21SSimon J. GerratyUT_TWICE_LITERAL= value literal 16*8d5c8e21SSimon J. Gerraty.export UT_TWICE_LITERAL 17*8d5c8e21SSimon J. Gerraty.export-literal UT_TWICE_LITERAL 18*8d5c8e21SSimon J. Gerraty 19*8d5c8e21SSimon J. Gerraty# XXX: After an .export, an .export-literal has no effect, even when the 20*8d5c8e21SSimon J. Gerraty# variable value contains a '$'. 21*8d5c8e21SSimon J. GerratyUT_TWICE_EXPR= value ${indirect:L} 22*8d5c8e21SSimon J. Gerraty.export UT_TWICE_EXPR 23*8d5c8e21SSimon J. Gerraty.export-literal UT_TWICE_EXPR 24*8d5c8e21SSimon J. Gerraty 25*8d5c8e21SSimon J. Gerraty# After an .export, an .unexport resets the variable's exported state, 26*8d5c8e21SSimon J. Gerraty# re-enabling a later .export-literal. 27*8d5c8e21SSimon J. GerratyUT_TWICE_EXPR_UNEXPORT= value ${indirect:L} 28*8d5c8e21SSimon J. Gerraty.export UT_TWICE_EXPR_UNEXPORT 29*8d5c8e21SSimon J. Gerraty.unexport UT_TWICE_EXPR_UNEXPORT 30*8d5c8e21SSimon J. Gerraty.export-literal UT_TWICE_EXPR_UNEXPORT 31*8d5c8e21SSimon J. Gerraty 322c3632d1SSimon J. Gerratyall: 33956e45f6SSimon J. Gerraty @echo "$$UT_VAR" 34*8d5c8e21SSimon J. Gerraty @echo "$$UT_TWICE_LITERAL" 35*8d5c8e21SSimon J. Gerraty @echo "$$UT_TWICE_EXPR" 36*8d5c8e21SSimon J. Gerraty @echo "$$UT_TWICE_EXPR_UNEXPORT" 37