From d11615f609d2cd58fb1305205a4fa975dc8e4657 Mon Sep 17 00:00:00 2001 From: Tomas Volf <~@wolfsden.cz> Date: Thu, 14 May 2026 21:26:16 +0200 Subject: environment: Allow setting environment variables with -E. * guix/scripts/environment.scm (show-environment-options-help) [-E]: Document the change. * guix/scripts/environment.scm (%options) [-E]: If arg contains =, split it and store under 'extra-env. * guix/scripts/environment.scm (launch-environment, launch-environment/fork) (launch-environment/container): Take and use `environment-variables' keyword argument. * guix/scripts/environment.scm (guix-environment*): Process 'environment-variables opts. * guix/profiles.scm (load-profile): Add `environment-variables' keyword argument. * doc/guix.texi (Invoking guix shell): Document the change. * tests/guix-environment.sh (GUIX_TEST_ZZZ): Test it. Change-Id: Ib1db19ef73dda8f561b05731079a96eda076e365 Signed-off-by: Maxim Cournoyer Modified-by: Maxim Cournoyer --- tests/guix-environment.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/guix-environment.sh b/tests/guix-environment.sh index 56cb289f2ff..450f0265221 100644 --- a/tests/guix-environment.sh +++ b/tests/guix-environment.sh @@ -49,18 +49,21 @@ test -x `sed -r 's/^export PATH="(.*)"/\1/' "$tmpdir/a"`/guile cmp "$tmpdir/a" "$tmpdir/b" -# Check '--preserve'. +# Check '--preserve', as well as its -E VAR=VALUE special case. GUIX_TEST_ABC=1 GUIX_TEST_DEF=2 GUIX_TEST_XYZ=3 +GUIX_TEST_ZZZ=4 export GUIX_TEST_ABC GUIX_TEST_DEF GUIX_TEST_XYZ guix environment --bootstrap --ad-hoc guile-bootstrap --pure \ --preserve='^GUIX_TEST_A' --preserve='^GUIX_TEST_D' \ + --preserve='^GUIX_TEST_Z' -E 'GUIX_TEST_ZZZ=overridden' \ -- "$SHELL" -c set > "$tmpdir/a" grep '^PATH=' "$tmpdir/a" grep '^GUIX_TEST_ABC=1' "$tmpdir/a" grep '^GUIX_TEST_DEF=2' "$tmpdir/a" grep '^GUIX_TEST_XYZ=3' "$tmpdir/a" && false +grep '^GUIX_TEST_ZZZ=overridden' "$tmpdir/a" # Make sure the exit value is preserved. if guix environment --bootstrap --ad-hoc guile-bootstrap --pure \ -- cgit v1.2.3