Skip to content

Commit 3c0d963

Browse files
miss-islingtonJ-M0
andauthored
[3.11] gh-112431: Unconditionally call hash -r (GH-112432) (GH-112492)
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]>
1 parent 42dd261 commit 3c0d963

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:-}"
@@ -61,9 +58,6 @@ if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
6158
export VIRTUAL_ENV_PROMPT
6259
fi
6360

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

0 commit comments

Comments
 (0)