Skip to content

Commit 38884a6

Browse files
J-M0Glyphack
authored andcommitted
pythongh-112431: Unconditionally call hash -r (pythonGH-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 `#!/bin/sh`-compatible shells like dash.
1 parent 6eb0115 commit 38884a6

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

Lib/venv/scripts/common/activate

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@ deactivate () {
1414
unset _OLD_VIRTUAL_PYTHONHOME
1515
fi
1616

17-
# This should detect bash and zsh, which have a hash command that must
18-
# be called to get it to forget past commands. Without forgetting
17+
# Call hash to forget past commands. Without forgetting
1918
# past commands the $PATH changes we made may not be respected
20-
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
21-
hash -r 2> /dev/null
22-
fi
19+
hash -r 2> /dev/null
2320

2421
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
2522
PS1="${_OLD_VIRTUAL_PS1:-}"
@@ -69,9 +66,6 @@ if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
6966
export PS1
7067
fi
7168

72-
# This should detect bash and zsh, which have a hash command that must
73-
# be called to get it to forget past commands. Without forgetting
69+
# Call hash to forget past commands. Without forgetting
7470
# past commands the $PATH changes we made may not be respected
75-
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
76-
hash -r 2> /dev/null
77-
fi
71+
hash -r 2> /dev/null

0 commit comments

Comments
 (0)