소스 검색

Fix abs_dirname for relative symlinks in same directory

Ref (abs_dirname in bats): https://github.com/sstephenson/bats/pull/224
Ref: https://github.com/rbenv/rbenv/pull/868

Fixes https://github.com/pyenv/pyenv/issues/580
pull/1216/head
Daniel Hahler 6 년 전
부모
커밋
4f21d9a2ea
3개의 변경된 파일22개의 추가작업 그리고 9개의 파일을 삭제
  1. +6
    -3
      libexec/pyenv
  2. +7
    -6
      plugins/python-build/bin/python-build
  3. +9
    -0
      test/pyenv_ext.bats

+ 6
- 3
libexec/pyenv 파일 보기

@ -41,12 +41,15 @@ else
# Use a subshell to avoid changing the current path
(
while [ -n "$path" ]; do
cd "${path%/*}"
local name="${path##*/}"
cd_path="${path%/*}"
if [[ "$cd_path" != "$path" ]]; then
cd "$cd_path"
fi
name="${path##*/}"
path="$(resolve_link "$name" || true)"
done
pwd
echo "$PWD"
)
}
fi

+ 7
- 6
plugins/python-build/bin/python-build 파일 보기

@ -60,20 +60,21 @@ resolve_link() {
}
abs_dirname() {
local cwd="$(pwd)"
local path="$1"
# Use a subshell to avoid modifying the current path
# Use a subshell to avoid changing the current path
(
while [ -n "$path" ]; do
cd "${path%/*}"
local name="${path##*/}"
cd_path="${path%/*}"
if [[ "$cd_path" != "$path" ]]; then
cd "$cd_path"
fi
name="${path##*/}"
path="$(resolve_link "$name" || true)"
done
pwd
echo "$PWD"
)
# cd "$cwd"
}
capitalize() {

+ 9
- 0
test/pyenv_ext.bats 파일 보기

@ -28,3 +28,12 @@ load test_helper
PYENV_FILE_ARG="${PYENV_TEST_DIR}/dir2/symlink.py" run pyenv echo PYENV_DIR
assert_output "${PYENV_TEST_DIR}/dir1"
}
@test "should handle relative symlinks for file argument (#580)" {
mkdir -p "${PYENV_TEST_DIR}"
cd "${PYENV_TEST_DIR}"
touch file.py
ln -s file.py symlink.py
PYENV_FILE_ARG="symlink.py" run pyenv echo PYENV_DIR
assert_output "${PYENV_TEST_DIR}"
}

불러오는 중...
취소
저장