fix "system" handling

This commit is contained in:
Yamashita Yuu 2012-12-19 23:58:39 +09:00
parent a16355fe33
commit 5b14236bac
3 changed files with 13 additions and 14 deletions

View file

@ -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
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

View file

@ -11,7 +11,7 @@ else
export PYENV_VERSION
fi
if [ -z "$versions" ] || [ "$versions" = "system" ] ; then
if [ -z "$versions" ]; then
echo "system"
exit
fi
@ -19,7 +19,7 @@ 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

View file

@ -52,13 +52,13 @@ 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}"
fi
if [ -x "$PYENV_COMMAND_PATH" ]; then
break
fi
fi
done
for script in $(pyenv-hooks which); do