From 67717c569edd5ade22309e3f87dd2b550db237e6 Mon Sep 17 00:00:00 2001 From: Alex Hornburg Date: Tue, 27 Sep 2022 20:32:42 +0100 Subject: shell.py: fix undefined variable in csh deactivate (#32816) This commit fixes #27027. The root cause of the issue is that the `SPACK_OLD_PROMPT` variable was evaluated in string interpolation regardless of whether the guard condition above evaluates to true or false. This commit uses the `eval` keyword to defer evaluation until the command is executed. Co-authored-by: Alexander Hornburg --- lib/spack/spack/environment/shell.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/environment/shell.py b/lib/spack/spack/environment/shell.py index 42d997ec96..50a4bcf657 100644 --- a/lib/spack/spack/environment/shell.py +++ b/lib/spack/spack/environment/shell.py @@ -65,8 +65,8 @@ def deactivate_header(shell): if shell == "csh": cmds += "unsetenv SPACK_ENV;\n" cmds += "if ( $?SPACK_OLD_PROMPT ) " - cmds += 'set prompt="$SPACK_OLD_PROMPT" && ' - cmds += "unsetenv SPACK_OLD_PROMPT;\n" + cmds += ' eval \'set prompt="$SPACK_OLD_PROMPT" &&' + cmds += " unsetenv SPACK_OLD_PROMPT';\n" cmds += "unalias despacktivate;\n" elif shell == "fish": cmds += "set -e SPACK_ENV;\n" -- cgit v1.2.3-60-g2f50