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

View file

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

View file

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