Skip to content

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

Closed
@J-M0

Description

@J-M0

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtopic-venvRelated to the venv moduletype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions