aboutsummaryrefslogtreecommitdiff
path: root/contrib/bmake/unit-tests/directive-export.mk
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bmake/unit-tests/directive-export.mk')
-rw-r--r--contrib/bmake/unit-tests/directive-export.mk27
1 files changed, 25 insertions, 2 deletions
diff --git a/contrib/bmake/unit-tests/directive-export.mk b/contrib/bmake/unit-tests/directive-export.mk
index 942d4b371bbd..08109814bcfd 100644
--- a/contrib/bmake/unit-tests/directive-export.mk
+++ b/contrib/bmake/unit-tests/directive-export.mk
@@ -1,4 +1,4 @@
-# $NetBSD: directive-export.mk,v 1.8 2021/02/16 19:01:18 rillig Exp $
+# $NetBSD: directive-export.mk,v 1.10 2023/11/19 09:45:19 rillig Exp $
#
# Tests for the .export directive.
#
@@ -35,10 +35,33 @@ VAR= value $$ ${INDIRECT}
.export ${:U}
-# Trigger the "This isn't going to end well" in ExportVarEnv.
+# Before a child process is started, whether for the '!=' assignment operator
+# or for the ':sh' modifier, all variables that were marked for being exported
+# are expanded and then exported. If expanding such a variable requires
+# running a child command, the marked-as-exported variables would need to be
+# exported first, ending in an endless loop. To avoid this endless loop,
+# don't export the variables while preparing a child process, see
+# ExportVarEnv.
EMPTY_SHELL= ${:sh}
.export EMPTY_SHELL # only marked for export at this point
_!= :;: # Force the variable to be actually exported.
+# If the '.export' directive exports a variable whose value contains a '$',
+# the actual export action is deferred until a subprocess is started, assuming
+# that only subprocesses access the environment variables. The ':localtime'
+# modifier depends on the 'TZ' environment variable, without any subprocess.
+export TZ=${UTC}
+# expect+1: 00:00:00
+.info ${%T:L:localtime=86400}
+INDIRECT_TZ= ${:UAmerica/Los_Angeles}
+TZ= ${INDIRECT_TZ}
+.export TZ
+# expect+1: 00:00:00
+.info ${%T:L:localtime=86400}
+_!= echo 'force exporting the environment variables'
+# expect+1: 16:00:00
+.info ${%T:L:localtime=86400}
+
+
all: