directive-export-literal.mk revision 1.8 1 # $NetBSD: directive-export-literal.mk,v 1.8 2024/06/01 18:44:05 rillig Exp $
2 #
3 # Tests for the .export-literal directive, which exports a variable value
4 # without expanding it.
5
6 UT_VAR= value with ${UNEXPANDED} expression
7
8 .export-literal UT_VAR
9
10 .export-literal # oops: missing argument
11
12 # After a variable whose value does not contain a '$' is exported, a following
13 # .export-literal can be skipped, to avoid a setenv call, which may leak
14 # memory on some platforms.
15 UT_TWICE_LITERAL= value literal
16 .export UT_TWICE_LITERAL
17 .export-literal UT_TWICE_LITERAL
18
19 # XXX: After an .export, an .export-literal has no effect, even when the
20 # variable value contains a '$'.
21 UT_TWICE_EXPR= value ${indirect:L}
22 .export UT_TWICE_EXPR
23 .export-literal UT_TWICE_EXPR
24
25 # After an .export, an .unexport resets the variable's exported state,
26 # re-enabling a later .export-literal.
27 UT_TWICE_EXPR_UNEXPORT= value ${indirect:L}
28 .export UT_TWICE_EXPR_UNEXPORT
29 .unexport UT_TWICE_EXPR_UNEXPORT
30 .export-literal UT_TWICE_EXPR_UNEXPORT
31
32 all:
33 @echo "$$UT_VAR"
34 @echo "$$UT_TWICE_LITERAL"
35 @echo "$$UT_TWICE_EXPR"
36 @echo "$$UT_TWICE_EXPR_UNEXPORT"
37