Module Name: src Committed By: rillig Date: Thu Nov 2 05:46:26 UTC 2023
Modified Files: src/usr.bin/make/unit-tests: var-op-append.mk Log Message: tests/make: test appending to an environment variable To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/var-op-append.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/var-op-append.mk diff -u src/usr.bin/make/unit-tests/var-op-append.mk:1.11 src/usr.bin/make/unit-tests/var-op-append.mk:1.12 --- src/usr.bin/make/unit-tests/var-op-append.mk:1.11 Thu Nov 2 05:14:58 2023 +++ src/usr.bin/make/unit-tests/var-op-append.mk Thu Nov 2 05:46:26 2023 @@ -1,4 +1,4 @@ -# $NetBSD: var-op-append.mk,v 1.11 2023/11/02 05:14:58 rillig Exp $ +# $NetBSD: var-op-append.mk,v 1.12 2023/11/02 05:46:26 rillig Exp $ # # Tests for the '+=' variable assignment operator, which appends to a # variable, creating it if necessary. @@ -56,4 +56,33 @@ VAR.${:U\$\$\$\$\$\$\$\$}+= dollars . error .endif + +# Appending to an environment variable in the global scope creates a global +# variable of the same name, taking its initial value from the environment +# variable. After the assignment, the environment variable is left as-is, +# the value of the global variable is not synced back to the environment +# variable. +export ENV_PLUS_GLOBAL=from-env-value +ENV_PLUS_GLOBAL+= appended-value +.if ${ENV_PLUS_GLOBAL} != "from-env-value appended-value" +. error +.endif +EXPORTED!= echo "$$ENV_PLUS_GLOBAL" +.if ${EXPORTED} != "from-env-value" +. error +.endif + +# Appending to an environment variable in the command line scope ignores the +# environment variable. +export ENV_PLUS_COMMAND=from-env-value +.MAKEFLAGS: ENV_PLUS_COMMAND+=appended-command +.if ${ENV_PLUS_COMMAND} != "appended-command" +. error ${ENV_PLUS_COMMAND} +.endif +EXPORTED!= echo "$$ENV_PLUS_GLOBAL" +.if ${EXPORTED} != "from-env-value" +. error +.endif + + all: