summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Hornburg <alexander.hornburg@xilinx.com>2022-09-27 20:32:42 +0100
committerGitHub <noreply@github.com>2022-09-27 12:32:42 -0700
commit67717c569edd5ade22309e3f87dd2b550db237e6 (patch)
treeed2fb7f4840050556592844b5272301332269bb9 /lib
parentcb9f174a7f663e259907bfdf57b3109c158b6614 (diff)
downloadspack-67717c569edd5ade22309e3f87dd2b550db237e6.tar.gz
spack-67717c569edd5ade22309e3f87dd2b550db237e6.tar.bz2
spack-67717c569edd5ade22309e3f87dd2b550db237e6.tar.xz
spack-67717c569edd5ade22309e3f87dd2b550db237e6.zip
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 <alexande@xilinx.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/environment/shell.py4
1 files changed, 2 insertions, 2 deletions
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"