serhiy-storchaka · GitHub

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. PATH and VIRTUAL_ENV are set, because they come earlier in the file, but the pydoc alias and rehash at the end are skipped, and _OLD_VIRTUAL_PROMPT is 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

Read the original on github.com ↗