소스 검색

Use realpath of scripts to determine relative locations (#308)

Just using paths relative to ${BASH_SOURCE} to access `libexec`
fails if the scripts are symlinked to a location,
such as when installed with Homebrew,
since the `libexec` directory is not linked into `brew --prefix`.

Implement a simple version of `realpath`
and run `${BASH_SOURCE}` through it.
This gets the actual installation directory
relative to which `libexec` is located.

Co-authored-by: Andrew Christianson <achristianson@edmunds.com>
pull/377/head
Andrew Christianson 1 년 전
committed by GitHub
부모
커밋
c4de2555b7
No known key found for this signature in database GPG 키 ID: 4AEE18F83AFDEB23
2개의 변경된 파일30개의 추가작업 그리고 2개의 파일을 삭제
  1. +15
    -1
      bin/pyenv-virtualenv-prefix
  2. +15
    -1
      bin/pyenv-virtualenvs

+ 15
- 1
bin/pyenv-virtualenv-prefix 파일 보기

@ -6,7 +6,21 @@
set -e
[ -n "$PYENV_DEBUG" ] && set -x
. "${BASH_SOURCE%/*}"/../libexec/pyenv-virtualenv-realpath
if [ -L "${BASH_SOURCE}" ]; then
READLINK=$(type -p greadlink readlink | head -1)
if [ -z "$READLINK" ]; then
echo "pyenv: cannot find readlink - are you missing GNU coreutils?" >&2
exit 1
fi
resolve_link() {
$READLINK -f "$1"
}
script_path=$(resolve_link ${BASH_SOURCE})
else
script_path=${BASH_SOURCE}
fi
. ${script_path%/*}/../libexec/pyenv-virtualenv-realpath
if [ -z "$PYENV_ROOT" ]; then
PYENV_ROOT="${HOME}/.pyenv"

+ 15
- 1
bin/pyenv-virtualenvs 파일 보기

@ -7,7 +7,21 @@
set -e
[ -n "$PYENV_DEBUG" ] && set -x
. "${BASH_SOURCE%/*}"/../libexec/pyenv-virtualenv-realpath
if [ -L "${BASH_SOURCE}" ]; then
READLINK=$(type -p greadlink readlink | head -1)
if [ -z "$READLINK" ]; then
echo "pyenv: cannot find readlink - are you missing GNU coreutils?" >&2
exit 1
fi
resolve_link() {
$READLINK -f "$1"
}
script_path=$(resolve_link ${BASH_SOURCE})
else
script_path=${BASH_SOURCE}
fi
. ${script_path%/*}/../libexec/pyenv-virtualenv-realpath
if [ -z "$PYENV_ROOT" ]; then
PYENV_ROOT="${HOME}/.pyenv"

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