Skip to content

venv/scripts/common/activate should unconditionally call hash -r #112431

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
J-M0 opened this issue Nov 26, 2023 · 0 comments
Closed

venv/scripts/common/activate should unconditionally call hash -r #112431

J-M0 opened this issue Nov 26, 2023 · 0 comments
Labels
stdlib Python modules in the Lib dir topic-venv Related to the venv module type-bug An unexpected behavior, bug, or error

Comments

@J-M0
Copy link
Contributor

J-M0 commented Nov 26, 2023

Bug report

Bug description:

The venv/scripts/common/activate script calls hash -r in two places to make sure the shell picks up the environment changes the script makes. Before that, it checks to see if the shell running the script is bash or zsh.

if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r 2> /dev/null
fi

if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r 2> /dev/null
fi

hash -r is specified by POSIX and is not exclusive to bash and zsh. This guard will prevent the script from calling hash -r in other #!/bin/sh-compatible shells like dash.

CPython versions tested on:

3.11, 3.12, 3.13

Operating systems tested on:

macOS, Windows

Linked PRs

@J-M0 J-M0 added the type-bug An unexpected behavior, bug, or error label Nov 26, 2023
@AlexWaygood AlexWaygood added stdlib Python modules in the Lib dir topic-venv Related to the venv module labels Nov 27, 2023
vsajip pushed a commit that referenced this issue Nov 28, 2023
The `activate` script calls `hash -r` in two places to make sure the shell picks
up the environment changes the script makes. Before that, it checks to
see if the shell running the script is bash or zsh.

`hash -r` is specified by POSIX and is not exclusive to bash and zsh.
This guard prevents the script from calling `hash -r` in other
`#!/bin/sh`-compatible shells like dash.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 28, 2023
The `activate` script calls `hash -r` in two places to make sure the shell picks
up the environment changes the script makes. Before that, it checks to
see if the shell running the script is bash or zsh.

`hash -r` is specified by POSIX and is not exclusive to bash and zsh.
This guard prevents the script from calling `hash -r` in other
`GH-!/bin/sh`-compatible shells like dash.
(cherry picked from commit a194938)

Co-authored-by: James Morris <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 28, 2023
The `activate` script calls `hash -r` in two places to make sure the shell picks
up the environment changes the script makes. Before that, it checks to
see if the shell running the script is bash or zsh.

`hash -r` is specified by POSIX and is not exclusive to bash and zsh.
This guard prevents the script from calling `hash -r` in other
`GH-!/bin/sh`-compatible shells like dash.
(cherry picked from commit a194938)

Co-authored-by: James Morris <[email protected]>
vsajip pushed a commit that referenced this issue Nov 28, 2023
gh-112431: Unconditionally call `hash -r` (GH-112432)

The `activate` script calls `hash -r` in two places to make sure the shell picks
up the environment changes the script makes. Before that, it checks to
see if the shell running the script is bash or zsh.

`hash -r` is specified by POSIX and is not exclusive to bash and zsh.
This guard prevents the script from calling `hash -r` in other
`GH-!/bin/sh`-compatible shells like dash.
(cherry picked from commit a194938)

Co-authored-by: James Morris <[email protected]>
vsajip pushed a commit that referenced this issue Nov 28, 2023
gh-112431: Unconditionally call `hash -r` (GH-112432)

The `activate` script calls `hash -r` in two places to make sure the shell picks
up the environment changes the script makes. Before that, it checks to
see if the shell running the script is bash or zsh.

`hash -r` is specified by POSIX and is not exclusive to bash and zsh.
This guard prevents the script from calling `hash -r` in other
`GH-!/bin/sh`-compatible shells like dash.
(cherry picked from commit a194938)

Co-authored-by: James Morris <[email protected]>
@vsajip vsajip closed this as completed Nov 28, 2023
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
The `activate` script calls `hash -r` in two places to make sure the shell picks
up the environment changes the script makes. Before that, it checks to
see if the shell running the script is bash or zsh.

`hash -r` is specified by POSIX and is not exclusive to bash and zsh.
This guard prevents the script from calling `hash -r` in other
`#!/bin/sh`-compatible shells like dash.
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
The `activate` script calls `hash -r` in two places to make sure the shell picks
up the environment changes the script makes. Before that, it checks to
see if the shell running the script is bash or zsh.

`hash -r` is specified by POSIX and is not exclusive to bash and zsh.
This guard prevents the script from calling `hash -r` in other
`#!/bin/sh`-compatible shells like dash.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-venv Related to the venv module type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants