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>
This commit is contained in:
Alex Hornburg 2022-09-27 20:32:42 +01:00 committed by GitHub
parent cb9f174a7f
commit 67717c569e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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"