Skip to content

🐛 fix(batch): preserve inherited shell punctuation - #3731

Merged
gaborbernat merged 2 commits into
pypa:mainfrom
gaborbernat:fix/0yrl-batch-path-delayed
Nov 20, 2026
Merged

gaborbernat merged 2 commits into
pypa:mainfrom
gaborbernat:fix/0yrl-batch-path-delayed

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Windows batch activation could change an inherited path or prompt before deactivation restored it. Under delayed expansion, literal ! characters could disappear. A quoted PATH entry such as "C:\Build ^ tools\bin" could lose the caret even with delayed expansion off. Fixes #3617.

The activation and deactivation scripts copy inherited values after the shell parses the assignment. The environment's scripts directory still leads PATH while active. On deactivation, the scripts restore the single-line values of PATH, PROMPT, PYTHONHOME, TCL_LIBRARY, TK_LIBRARY, and PKG_CONFIG_PATH, even if the caller changed delayed expansion between the two calls.

Reported by oss-scanner: ANT-2026-0YRL0MX4.

With delayed expansion enabled, cmd rescans inherited values after a
%VAR% substitution and replaces embedded !name! text. Read the source
through !VAR! in that mode so activation and deactivation preserve
PATH, prompt, and tool paths.
@gaborbernat
gaborbernat force-pushed the fix/0yrl-batch-path-delayed branch from 5942dce to db21c47 Compare November 20, 2026 15:27
@gaborbernat gaborbernat changed the title 🐛 fix(batch): preserve ! in PATH 🐛 fix(batch): preserve ! in inherited values Nov 20, 2026
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 16:17
@gaborbernat
gaborbernat marked this pull request as draft November 20, 2026 20:49
@gaborbernat gaborbernat changed the title 🐛 fix(batch): preserve ! in inherited values 🐛 fix(batch): preserve inherited shell punctuation Nov 20, 2026
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 22:00
@gaborbernat
gaborbernat merged commit 22c5186 into pypa:main Nov 20, 2026
81 checks passed
@gaborbernat
gaborbernat deleted the fix/0yrl-batch-path-delayed branch November 23, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Batch activation changes inherited PATH under delayed expansion

1 participant