Skip to content

Commit 49494c4

Browse files
miss-islingtonJ-M0
andauthored
[3.12] gh-112431: Unconditionally call hash -r (GH-112432) (GH-112493)
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 e28722e commit 49494c4

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:-}"
@@ -68,9 +65,6 @@ if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
6865
export VIRTUAL_ENV_PROMPT
6966
fi
7067

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

0 commit comments

Comments
 (0)