Skip to content

Commit d82cddf

Browse files
miss-islingtonserhiy-storchakaclaude
authored
[3.13] gh-154399: Fix venv activate.csh in a non-interactive shell (GH-154400) (GH-154410)
activate.csh saved the prompt unconditionally, but the prompt variable only exists in interactive shells, and csh fails on an undefined variable. (cherry picked from commit 4448705) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent a2b6e57 commit d82cddf

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

Lib/venv/scripts/posix/activate.csh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ setenv PATH "$VIRTUAL_ENV/"__VENV_BIN_NAME__":$PATH"
1616
setenv VIRTUAL_ENV_PROMPT __VENV_PROMPT__
1717

1818

19-
set _OLD_VIRTUAL_PROMPT="$prompt"
19+
if ($?prompt) then
20+
set _OLD_VIRTUAL_PROMPT="$prompt"
2021

21-
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
22-
set prompt = "("__VENV_PROMPT__") $prompt:q"
22+
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
23+
set prompt = "("__VENV_PROMPT__") $prompt:q"
24+
endif
2325
endif
2426

2527
alias pydoc python -m pydoc
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix :mod:`venv` activation in a non-interactive csh:
2+
``activate.csh`` no longer fails
3+
when the ``prompt`` variable is not set.

0 commit comments

Comments
 (0)