From c7f0fb1de62bceee0477492357a44293e9f4dfba Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Sat, 26 Jul 2014 13:22:12 +0900 Subject: [PATCH 1/2] Set `PYENV_COMMAND_PATH` even if multiple candidate versions found. If multiple candidates found in pyenv, display a warning message and just choose first one for `PYENV_COMMAND_PATH`. --- etc/pyenv.d/which/whence.bash | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/etc/pyenv.d/which/whence.bash b/etc/pyenv.d/which/whence.bash index 889436c..11a84fe 100755 --- a/etc/pyenv.d/which/whence.bash +++ b/etc/pyenv.d/which/whence.bash @@ -1,6 +1,9 @@ if [ -n "$PYENV_COMMAND" ] && [ ! -x "$PYENV_COMMAND_PATH" ]; then versions=($(pyenv-whence "${PYENV_COMMAND}" 2>/dev/null || true)) - if [ "${#versions[@]}" -eq 1 ]; then + if [ -n "${versions}" ]; then + if [ "${#versions[@]}" -gt 1 ]; then + echo "pyenv-implicit: found multiple ${PYENV_COMMAND} in pyenv. Use version ${versions[0]}." 1>&2 + fi PYENV_COMMAND_PATH="${PYENV_ROOT}/versions/${versions[0]}/bin/${PYENV_COMMAND}" fi fi From f6e9b229d9f7513c1f0993edd5cd48fdcd941959 Mon Sep 17 00:00:00 2001 From: daten-kieker Date: Mon, 18 Feb 2019 14:46:57 +0100 Subject: [PATCH 2/2] Use latest version instead of first one Instead of using the first version among the candidates found take the last one. Since versions are sorted alphabetically this should be the latest installed version. Solves #3 --- etc/pyenv.d/which/whence.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/pyenv.d/which/whence.bash b/etc/pyenv.d/which/whence.bash index 11a84fe..7faf04f 100755 --- a/etc/pyenv.d/which/whence.bash +++ b/etc/pyenv.d/which/whence.bash @@ -2,8 +2,8 @@ if [ -n "$PYENV_COMMAND" ] && [ ! -x "$PYENV_COMMAND_PATH" ]; then versions=($(pyenv-whence "${PYENV_COMMAND}" 2>/dev/null || true)) if [ -n "${versions}" ]; then if [ "${#versions[@]}" -gt 1 ]; then - echo "pyenv-implicit: found multiple ${PYENV_COMMAND} in pyenv. Use version ${versions[0]}." 1>&2 + echo "pyenv-implicit: found multiple ${PYENV_COMMAND} in pyenv. Use version ${versions[-1]}." 1>&2 fi - PYENV_COMMAND_PATH="${PYENV_ROOT}/versions/${versions[0]}/bin/${PYENV_COMMAND}" + PYENV_COMMAND_PATH="${PYENV_ROOT}/versions/${versions[-1]}/bin/${PYENV_COMMAND}" fi fi