From 5b14236bac71b2a0bb9d7aa5c2be4eabce77b86a Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Wed, 19 Dec 2012 23:58:39 +0900 Subject: [PATCH] fix "system" handling --- libexec/pyenv-prefix | 13 ++++++------- libexec/pyenv-version-name | 6 +++--- libexec/pyenv-which | 8 ++++---- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/libexec/pyenv-prefix b/libexec/pyenv-prefix index 1869983e..287ad4f9 100755 --- a/libexec/pyenv-prefix +++ b/libexec/pyenv-prefix @@ -16,15 +16,14 @@ else IFS=: versions=($(pyenv-version-name)) fi -if [ "$versions" = "system" ]; then - PYTHON_PATH="$(pyenv-which python)" - echo "${PYTHON_PATH%/*}" - exit -fi - PYENV_PREFIX_PATHS=() for version in "${versions[@]}"; do - PYENV_PREFIX_PATH="${PYENV_ROOT}/versions/${version}" + if [ "$version" = "system" ]; then + PYTHON_PATH="$(pyenv-which python || true)" + PYENV_PREFIX_PATH="${PYTHON_PATH%/*}" + else + PYENV_PREFIX_PATH="${PYENV_ROOT}/versions/${version}" + fi if [ -d "$PYENV_PREFIX_PATH" ]; then PYENV_PREFIX_PATHS=("${PYENV_PREFIX_PATHS[@]}" "$PYENV_PREFIX_PATH") else diff --git a/libexec/pyenv-version-name b/libexec/pyenv-version-name index 52bbd958..45646a07 100755 --- a/libexec/pyenv-version-name +++ b/libexec/pyenv-version-name @@ -11,15 +11,15 @@ else export PYENV_VERSION fi -if [ -z "$versions" ] || [ "$versions" = "system" ] ; then +if [ -z "$versions" ]; then echo "system" exit fi for version in "${versions[@]}"; do PYENV_VERSION_PATH="${PYENV_ROOT}/versions/${version}" - - if [ ! -d "$PYENV_VERSION_PATH" ]; then + + if [ "$version" != "system" ] && [ ! -d "$PYENV_VERSION_PATH" ]; then echo "pyenv: version \`$version' is not installed" >&2 exit 1 fi diff --git a/libexec/pyenv-which b/libexec/pyenv-which index d110f157..24a573a3 100755 --- a/libexec/pyenv-which +++ b/libexec/pyenv-which @@ -52,12 +52,12 @@ fi for version in "${versions[@]}"; do if [ "$version" = "system" ]; then PATH="$(remove_from_path "${PYENV_ROOT}/shims")" - PYENV_COMMAND_PATH="$(command -v "$PYENV_COMMAND")" + PYENV_COMMAND_PATH="$(command -v "$PYENV_COMMAND" || true)" else PYENV_COMMAND_PATH="${PYENV_ROOT}/versions/${version}/bin/${PYENV_COMMAND}" - if [ -x "$PYENV_COMMAND_PATH" ]; then - break - fi + fi + if [ -x "$PYENV_COMMAND_PATH" ]; then + break fi done