Bug report
source bin/activate.csh fails in a non-interactive shell, because it saves the prompt unconditionally:
set _OLD_VIRTUAL_PROMPT="$prompt"
prompt is only set in interactive shells, and csh fails on an undefined variable:
prompt: Undefined variable.
The activation is incomplete in both implementations, but the effect differs:
- with csh (OpenBSD) the error is fatal and the script exits with status 1;
- with tcsh (FreeBSD, NetBSD, DragonFly BSD) it only aborts sourcing and the exit status stays 0, so the failure is silent.
PATHandVIRTUAL_ENVare set, because they come earlier in the file, but thepydocalias andrehashat the end are skipped, and_OLD_VIRTUAL_PROMPTis never saved.
test_venv.test_special_chars_csh fails on OpenBSD for this reason. It passes on tcsh platforms because it only checks what is set before the failing line.
The prompt is not needed in a non-interactive shell, so the block can be guarded with if ($?prompt). The deactivate alias already handles an unset _OLD_VIRTUAL_PROMPT: it is invoked that way at activation, before the variable is set.
Linked PRs
- gh-154399: Fix venv activate.csh in a non-interactive shell #154400
- [3.15] gh-154399: Fix venv activate.csh in a non-interactive shell (GH-154400) #154408
- [3.14] gh-154399: Fix venv activate.csh in a non-interactive shell (GH-154400) #154409
- [3.13] gh-154399: Fix venv activate.csh in a non-interactive shell (GH-154400) #154410