From 372ffab430e1f445245f48be54b8f3686373d03b Mon Sep 17 00:00:00 2001 From: Christian Fredrik Johnsen Date: Sun, 22 Dec 2024 13:40:47 +0100 Subject: [PATCH] fix: look for `-m` followed by `pip` instead of looking for `python -m pip` It isn't necessarily the case that the command will be python, it can be both python3, python2, python3.12, etc. --- pyenv.d/exec/pip-rehash.bash | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pyenv.d/exec/pip-rehash.bash b/pyenv.d/exec/pip-rehash.bash index 4cfca0b1..79f96721 100644 --- a/pyenv.d/exec/pip-rehash.bash +++ b/pyenv.d/exec/pip-rehash.bash @@ -6,9 +6,13 @@ if [[ $PYENV_REHASH_COMMAND =~ ^(pip|easy_install)[23](\.\d)?$ ]]; then PYENV_REHASH_COMMAND="${BASH_REMATCH[1]}" fi -if [[ $1 == "python" && $2 == "-m" && $3 == "pip" ]]; then - PYENV_REHASH_COMMAND="pip" -fi +for (( i=1; i<$#; i++ )); do + next=$((i+1)) + if [[ ${!i} == "-m" && ${!next} == "pip" ]]; then + PYENV_REHASH_COMMAND="pip" + break + fi +done if [ -x "${PYENV_PIP_REHASH_ROOT}/${PYENV_REHASH_COMMAND}" ]; then PYENV_COMMAND_PATH="${PYENV_PIP_REHASH_ROOT}/${PYENV_REHASH_COMMAND##*/}"