-
-
Notifications
You must be signed in to change notification settings - Fork 36.8k
venv: activate.csh fails in a non-interactive shell #154399
Copy link
Copy link
Closed
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-venvRelated to the venv moduleRelated to the venv moduletype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Activity
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-venvRelated to the venv moduleRelated to the venv moduletype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Bug report
source bin/activate.cshfails in a non-interactive shell, because it saves the prompt unconditionally:promptis only set in interactive shells, and csh fails on an undefined variable:The activation is incomplete in both implementations, but the effect differs:
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_cshfails 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). Thedeactivatealias already handles an unset_OLD_VIRTUAL_PROMPT: it is invoked that way at activation, before the variable is set.Linked PRs