Module Name:    src
Committed By:   rillig
Date:           Sat Oct  3 09:48:40 UTC 2020

Modified Files:
        src/usr.bin/make/unit-tests: make-exported.exp make-exported.mk

Log Message:
make(1): explain the purpose of the test make-exported


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/make-exported.exp \
    src/usr.bin/make/unit-tests/make-exported.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/make-exported.exp
diff -u src/usr.bin/make/unit-tests/make-exported.exp:1.1 src/usr.bin/make/unit-tests/make-exported.exp:1.2
--- src/usr.bin/make/unit-tests/make-exported.exp:1.1	Sun Aug  9 12:59:16 2020
+++ src/usr.bin/make/unit-tests/make-exported.exp	Sat Oct  3 09:48:40 2020
@@ -1,3 +1,3 @@
--literal=make-exported-value
+-literal=make-exported-value-literal
 UT_VAR=
 exit status 0
Index: src/usr.bin/make/unit-tests/make-exported.mk
diff -u src/usr.bin/make/unit-tests/make-exported.mk:1.1 src/usr.bin/make/unit-tests/make-exported.mk:1.2
--- src/usr.bin/make/unit-tests/make-exported.mk:1.1	Sun Aug  9 12:59:16 2020
+++ src/usr.bin/make/unit-tests/make-exported.mk	Sat Oct  3 09:48:40 2020
@@ -1,16 +1,29 @@
-# $NetBSD: make-exported.mk,v 1.1 2020/08/09 12:59:16 rillig Exp $
+# $NetBSD: make-exported.mk,v 1.2 2020/10/03 09:48:40 rillig Exp $
 #
 # As of 2020-08-09, the code in Var_Export is shared between the .export
 # directive and the .MAKE.EXPORTED variable.  This leads to non-obvious
 # behavior for certain variable assignments.
 
--env=		make-exported-value
--literal=	make-exported-value
+-env=		make-exported-value-env
+-literal=	make-exported-value-literal
 UT_VAR=		${UNEXPANDED}
 
 # The following behavior is probably not intended.
-.MAKE.EXPORTED=		-env		# like .export-env
-.MAKE.EXPORTED=		-literal UT_VAR	# like .export-literal PATH
+.MAKE.EXPORTED=		-env		# behaves like .export-env
+
+# If the value of .MAKE.EXPORTED starts with "-literal", make behaves like
+# a mixture of .export-literal and a regular .export.
+# XXX: This is due to a sloppy implementation, reusing code in places where
+# it is not appropriate.
+#
+# In Parse_DoVar, the code path for MAKE_EXPORTED is taken, calling Var_Export
+# in turn.  There, the code path for .export-literal is taken, and the
+# environment variable UT_VAR is set to ${UNEXPANDED}, as expected.
+# Later, in Compat_RunCommand, in the child process after vfork,
+# Var_ExportVars is called, which treats "-literal" as an ordinary variable
+# name, therefore exports it and also overwrites the previously exported
+# UT_VAR with the expanded value.
+.MAKE.EXPORTED=		-literal UT_VAR
 
 all:
 	@env | sort | grep -E '^UT_|make-exported-value' || true

Reply via email to