diff --git a/libexec/pyenv b/libexec/pyenv index c7564a88..075aa7b7 100755 --- a/libexec/pyenv +++ b/libexec/pyenv @@ -20,41 +20,6 @@ abort() { exit 1 } -if enable -f "${BASH_SOURCE%/*}"/../libexec/pyenv-realpath.dylib realpath 2>/dev/null; then - abs_dirname() { - local path - path="$(realpath "$1")" - echo "${path%/*}" - } -else - [ -z "$PYENV_NATIVE_EXT" ] || abort "failed to load \`realpath' builtin" - - READLINK=$(type -P greadlink readlink | head -1) - [ -n "$READLINK" ] || abort "cannot find readlink - are you missing GNU coreutils?" - - resolve_link() { - $READLINK "$1" - } - - abs_dirname() { - local path="$1" - - # Use a subshell to avoid changing the current path - ( - while [ -n "$path" ]; do - cd_path="${path%/*}" - if [[ "$cd_path" != "$path" ]]; then - cd "$cd_path" - fi - name="${path##*/}" - path="$(resolve_link "$name" || true)" - done - - echo "$PWD" - ) - } -fi - if [ -z "${PYENV_ROOT}" ]; then PYENV_ROOT="${HOME}/.pyenv" else @@ -76,7 +41,8 @@ export PYENV_DIR shopt -s nullglob -bin_path="$(abs_dirname "$0")" +pyenv_bin="${BASH_SOURCE:-$0}" +bin_path="$(cd "${pyenv_bin%/*}"/../libexec && pwd -P)" for plugin_bin in "${bin_path%/*}"/plugins/*/bin; do PATH="${plugin_bin}:${PATH}" done diff --git a/libexec/pyenv-hooks b/libexec/pyenv-hooks index 1b8c528d..2a2cf175 100755 --- a/libexec/pyenv-hooks +++ b/libexec/pyenv-hooks @@ -21,43 +21,12 @@ if [ -z "$PYENV_COMMAND" ]; then exit 1 fi -if ! enable -f "${BASH_SOURCE%/*}"/pyenv-realpath.dylib realpath 2>/dev/null; then - if [ -n "$PYENV_NATIVE_EXT" ]; then - echo "pyenv: failed to load \`realpath' builtin" >&2 - exit 1 - fi -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 "$1" -} - -realpath() { - local path="$1" - local name - # Use a subshell to avoid changing the current path - ( - while [ -n "$path" ]; do - name="${path##*/}" - [ "$name" = "$path" ] || cd "${path%/*}" - path="$(resolve_link "$name" || true)" - done - - echo "${PWD}/$name" - ) -} -fi - IFS=: hook_paths=($PYENV_HOOK_PATH) shopt -s nullglob for path in "${hook_paths[@]}"; do for script in "$path/$PYENV_COMMAND"/*.bash; do - realpath "$script" + echo "$script" done done shopt -u nullglob diff --git a/libexec/pyenv-versions b/libexec/pyenv-versions index e4bb6264..3d3c0042 100755 --- a/libexec/pyenv-versions +++ b/libexec/pyenv-versions @@ -25,43 +25,14 @@ for arg; do esac done +canonicalize_dir() { + { cd "$1" && pwd -P + } 2>/dev/null || echo "$1" +} + versions_dir="${PYENV_ROOT}/versions" - -if ! enable -f "${BASH_SOURCE%/*}"/pyenv-realpath.dylib realpath 2>/dev/null; then - if [ -n "$PYENV_NATIVE_EXT" ]; then - echo "pyenv: failed to load \`realpath' builtin" >&2 - exit 1 - fi - - 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 "$1" - } - - realpath() { - local path="$1" - local name - - # Use a subshell to avoid changing the current path - ( - while [ -n "$path" ]; do - name="${path##*/}" - [ "$name" = "$path" ] || cd "${path%/*}" - path="$(resolve_link "$name" || true)" - done - - echo "${PWD}/$name" - ) - } -fi - if [ -d "$versions_dir" ]; then - versions_dir="$(realpath "$versions_dir")" + versions_dir="$(canonicalize_dir "$versions_dir")" fi if ((${BASH_VERSINFO[0]} > 3)); then @@ -138,7 +109,7 @@ fi for path in "${versions_dir_entries[@]}"; do if [ -d "$path" ]; then if [ -n "$skip_aliases" ] && [ -L "$path" ]; then - target="$(realpath "$path")" + target="$(canonicalize_dir "$path")" [ "${target%/*}" != "$versions_dir" ] || continue [ "${target%/*/envs/*}" != "$versions_dir" ] || continue fi