-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
gh-111501: venv: do not export PS1 in activate #105279
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
base: main
Are you sure you want to change the base?
Conversation
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
Is there some discussion somewhere about this? What problem is being solved here? |
Not recently that I'm aware, but a quick look turns up [1]. Exporting PS1 isn't really relevant to venv's purpose, and it is incorrect in the case that a different subshell is started, since prompt expansion differs between shells. The only sense in exporting something is if you mean for processes to inherit the value, and PS1 is a parameter special to current interactive shell. For example, in zsh my PS1 is currently:
Obviously, that isn't meaningful to a bash shell. Personally I notice this when starting [1] https://unix.stackexchange.com/questions/247585/to-export-or-not-to-export-bash-ps1-variable TBH, I think there is an even better argument to be made that the PS1 modifications should be dropped altogether. It's strangely invasive and really unnecessary since VIRTUAL_ENV is already set and exported. An interested user could surely just include VIRTUAL_ENV in PS1 in a way that expands to nothing if it is unset. Or, if they prefer, include it only in zsh's RPROMPT, or include it only in the terminal window title, or include it somewhere in the middle of their normal prompt, add colors, etc.... Not to mention that the current method preculdes modifying the prompt persistently in any way while a venv is active, since PS1 will be completely overwritten again when the venv is deactivated. You can always craft some prompt modifying functions that the user can slap in postactivate if they want the original behavior back, or just place them in postactivate by default if you don't want to be disruptive. |
I'm more worried about backward compatibility when considering changes in this area. It's been like this for a long time (and AFAIK |
#111501 explains why exporting |
Updated to resolve conflicts. |
Kindly pinging |
PS1 is a parameter special to the current interactive shell. It does not need to be exported to the environment. Exporting PS1 is not useful, and will break different shells spawned by the current interactive shell.
PS1 is a global parameter. It does not need (and should not be) exported to the users environment.