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)) IFS=: versions=($(pyenv-version-name))
fi fi
if [ "$versions" = "system" ]; then
PYTHON_PATH="$(pyenv-which python)"
echo "${PYTHON_PATH%/*}"
exit
fi
PYENV_PREFIX_PATHS=() PYENV_PREFIX_PATHS=()
for version in "${versions[@]}"; do 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 if [ -d "$PYENV_PREFIX_PATH" ]; then
PYENV_PREFIX_PATHS=("${PYENV_PREFIX_PATHS[@]}" "$PYENV_PREFIX_PATH") PYENV_PREFIX_PATHS=("${PYENV_PREFIX_PATHS[@]}" "$PYENV_PREFIX_PATH")
else else

View file

@ -11,15 +11,15 @@ else
export PYENV_VERSION export PYENV_VERSION
fi fi
if [ -z "$versions" ] || [ "$versions" = "system" ] ; then if [ -z "$versions" ]; then
echo "system" echo "system"
exit exit
fi fi
for version in "${versions[@]}"; do for version in "${versions[@]}"; do
PYENV_VERSION_PATH="${PYENV_ROOT}/versions/${version}" 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 echo "pyenv: version \`$version' is not installed" >&2
exit 1 exit 1
fi fi

View file

@ -52,12 +52,12 @@ fi
for version in "${versions[@]}"; do for version in "${versions[@]}"; do
if [ "$version" = "system" ]; then if [ "$version" = "system" ]; then
PATH="$(remove_from_path "${PYENV_ROOT}/shims")" PATH="$(remove_from_path "${PYENV_ROOT}/shims")"
PYENV_COMMAND_PATH="$(command -v "$PYENV_COMMAND")" PYENV_COMMAND_PATH="$(command -v "$PYENV_COMMAND" || true)"
else else
PYENV_COMMAND_PATH="${PYENV_ROOT}/versions/${version}/bin/${PYENV_COMMAND}" PYENV_COMMAND_PATH="${PYENV_ROOT}/versions/${version}/bin/${PYENV_COMMAND}"
if [ -x "$PYENV_COMMAND_PATH" ]; then fi
break if [ -x "$PYENV_COMMAND_PATH" ]; then
fi break
fi fi
done done