Merge pull request #661 from yyuu/workaroud-bin-python

Add workaround for `/bin/python`
This commit is contained in:
Yamashita, Yuu 2016-08-03 22:48:46 +09:00 committed by GitHub
commit 740fbe4bda
2 changed files with 13 additions and 0 deletions

View file

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

View file

@ -24,6 +24,18 @@ load test_helper
assert_success "$PYENV_TEST_DIR"
}
@test "prefix for system in /" {
mkdir -p "${BATS_TEST_DIRNAME}/libexec"
cat >"${BATS_TEST_DIRNAME}/libexec/pyenv-which" <<OUT
#!/bin/sh
echo /bin/python
OUT
chmod +x "${BATS_TEST_DIRNAME}/libexec/pyenv-which"
PYENV_VERSION="system" run pyenv-prefix
assert_success "/"
rm -f "${BATS_TEST_DIRNAME}/libexec/pyenv-which"
}
@test "prefix for invalid system" {
PATH="$(path_without python)" run pyenv-prefix system
assert_failure "pyenv: system version not found in PATH"