pyenv-prefix should return proper prefix of system version (fixes #391)

This commit is contained in:
Yamashita Yuu 2015-06-27 01:05:15 +09:00
parent 7b797c3797
commit 114063495f
2 changed files with 12 additions and 1 deletions

View file

@ -30,7 +30,7 @@ OLDIFS="$IFS"
{ IFS=: { IFS=:
for version in ${PYENV_VERSION}; do for version in ${PYENV_VERSION}; do
if [ "$version" = "system" ]; then if [ "$version" = "system" ]; then
if PYTHON_PATH="$(pyenv-which python 2>/dev/null)"; then if PYTHON_PATH="$(PYENV_VERSION="${version}" pyenv-which python 2>/dev/null)"; then
PYENV_PREFIX_PATH="${PYTHON_PATH%/bin/*}" PYENV_PREFIX_PATH="${PYTHON_PATH%/bin/*}"
else else
echo "pyenv: system version not found in PATH" >&2 echo "pyenv: system version not found in PATH" >&2

View file

@ -1,3 +1,14 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load test_helper load test_helper
@test "prefixes" {
mkdir -p "${PYENV_TEST_DIR}/bin"
touch "${PYENV_TEST_DIR}/bin/python"
chmod +x "${PYENV_TEST_DIR}/bin/python"
mkdir -p "${PYENV_ROOT}/versions/2.7.10"
PYENV_VERSION="system:2.7.10" run pyenv-prefix
assert_success "${PYENV_TEST_DIR}:${PYENV_ROOT}/versions/2.7.10"
PYENV_VERSION="2.7.10:system" run pyenv-prefix
assert_success "${PYENV_ROOT}/versions/2.7.10:${PYENV_TEST_DIR}"
}