Skip to content

venv activate.csh fails when user prompt contains newline #122765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brandyn opened this issue Aug 6, 2024 · 1 comment
Closed

venv activate.csh fails when user prompt contains newline #122765

brandyn opened this issue Aug 6, 2024 · 1 comment
Labels
easy topic-venv Related to the venv module type-bug An unexpected behavior, bug, or error

Comments

@brandyn
Copy link

brandyn commented Aug 6, 2024

Bug report

Bug description:

activate.csh uses "$prompt" in quotes like that, which fails when the user prompt contains a newline (error: unbalanced quotes).

Using $prompt:q or "$prompt:q" solves this with no harm, at least in tcsh (not sure about vanilla csh), at least for activate. (Deactivate may have similar issue.)

CPython versions tested on:

3.11

Operating systems tested on:

Linux

Linked PRs

@brandyn brandyn added the type-bug An unexpected behavior, bug, or error label Aug 6, 2024
@Eclips4 Eclips4 added the topic-venv Related to the venv module label Aug 7, 2024
JacekDuszenko added a commit to JacekDuszenko/cpython that referenced this issue Sep 5, 2024
@JacekDuszenko
Copy link
Contributor

sent a PR with a fix however there is a similar issue with __VENV_PROMPT__ variable. When you set a custom prompt e.g. with --prompt='"' the script crashes @ https://github.com/python/cpython/blob/main/Lib/venv/scripts/posix/activate.csh#L22.

It's fixable by extracting the concatenated __VENV_PROMPT__ and prompt to a separate variable and then using it with ":q" on the next line while setting the prompt.
Can send another PR with a fix if sounds good.

@picnixz picnixz changed the title venv activate.csh fails when user prompt contains newline. Easy to fix. venv activate.csh fails when user prompt contains newline Sep 6, 2024
@picnixz picnixz added the easy label Sep 6, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 17, 2024
…d quotes and newlines (pythonGH-123751)

(cherry picked from commit a15a584)

Co-authored-by: Jacek <[email protected]>
savannahostrowski pushed a commit to savannahostrowski/cpython that referenced this issue Sep 22, 2024
brettcannon added a commit that referenced this issue Oct 10, 2024
…ed quotes and newlines (GH-123751) (GH-124185)

gh-122765: make prompt in activate.csh robust against unbalanced quotes and newlines (GH-123751)
(cherry picked from commit a15a584)

Co-authored-by: Jacek <[email protected]>
Co-authored-by: Brett Cannon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy topic-venv Related to the venv module type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

5 participants