make-exported.mk revision 1.3 1 # $NetBSD: make-exported.mk,v 1.3 2020/10/03 10:31:05 rillig Exp $
2 #
3 # As of 2020-08-09, the code in Var_Export is shared between the .export
4 # directive and the .MAKE.EXPORTED variable. This leads to non-obvious
5 # behavior for certain variable assignments.
6
7 -env= make-exported-value-env
8 -literal= make-exported-value-literal
9 UT_VAR= ${UNEXPANDED}
10
11 # The following behavior is probably not intended.
12 .MAKE.EXPORTED= -env # behaves like .export-env
13
14 # If the value of .MAKE.EXPORTED starts with "-literal", make behaves like
15 # a mixture of .export-literal and a regular .export.
16 # XXX: This is due to a sloppy implementation, reusing code in places where
17 # it is not appropriate.
18 #
19 # In Parse_DoVar, the code path for MAKE_EXPORTED is taken, calling Var_Export
20 # in turn. There, the code path for .export-literal is taken, and the
21 # environment variable UT_VAR is set to ${UNEXPANDED}, as expected.
22 # Later, in Compat_RunCommand, in the child process after vfork,
23 # Var_ExportVars is called, which treats "-literal" as an ordinary variable
24 # name, therefore exports it and also overwrites the previously exported
25 # UT_VAR with the expanded value.
26 #
27 # Since 2020-10-03, the "variable" named "-literal" is not exported anymore.
28 .MAKE.EXPORTED= -literal UT_VAR
29
30 all:
31 @env | sort | grep -E '^UT_|make-exported-value' || true
32