2021-06-25 18:16:24 +00:00
|
|
|
# $NetBSD: directive-export.mk,v 1.8 2021/02/16 19:01:18 rillig Exp $
|
2020-09-05 16:11:04 +00:00
|
|
|
#
|
|
|
|
# Tests for the .export directive.
|
2021-01-14 01:24:34 +00:00
|
|
|
#
|
|
|
|
# See also:
|
|
|
|
# directive-misspellings.mk
|
2020-09-05 16:11:04 +00:00
|
|
|
|
|
|
|
# TODO: Implementation
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
INDIRECT= indirect
|
|
|
|
VAR= value $$ ${INDIRECT}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
# Before 2020-12-13, this unusual expression invoked undefined behavior since
|
|
|
|
# it accessed out-of-bounds memory via Var_Export -> ExportVar -> MayExport.
|
|
|
|
.export ${:U }
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
# A variable is exported using the .export directive.
|
|
|
|
# During that, its value is expanded, just like almost everywhere else.
|
|
|
|
.export VAR
|
|
|
|
.if ${:!env | grep '^VAR'!} != "VAR=value \$ indirect"
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
|
|
|
# Undefining a variable that has been exported implicitly removes it from
|
|
|
|
# the environment of all child processes.
|
|
|
|
.undef VAR
|
|
|
|
.if ${:!env | grep '^VAR' || true!} != ""
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
2021-06-25 18:16:24 +00:00
|
|
|
# No syntactical argument means to export all variables.
|
2021-01-14 01:24:34 +00:00
|
|
|
.export
|
2020-11-20 03:54:37 +00:00
|
|
|
|
2021-06-25 18:16:24 +00:00
|
|
|
# An empty argument means no additional variables to export.
|
|
|
|
.export ${:U}
|
|
|
|
|
|
|
|
|
|
|
|
# Trigger the "This isn't going to end well" in ExportVarEnv.
|
|
|
|
EMPTY_SHELL= ${:sh}
|
|
|
|
.export EMPTY_SHELL # only marked for export at this point
|
|
|
|
_!= :;: # Force the variable to be actually exported.
|
|
|
|
|
|
|
|
|
2020-09-05 16:11:04 +00:00
|
|
|
all:
|