Compare commits

...

1 Commits

Author SHA1 Message Date
Yamashita, Yuu
c743da4a03
Attempt to apply equivalent functionalities as rbenv/rbenv#1428 2022-09-20 11:11:04 +09:00
3 changed files with 10 additions and 104 deletions

View File

@ -20,41 +20,6 @@ abort() {
exit 1 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 if [ -z "${PYENV_ROOT}" ]; then
PYENV_ROOT="${HOME}/.pyenv" PYENV_ROOT="${HOME}/.pyenv"
else else
@ -76,7 +41,8 @@ export PYENV_DIR
shopt -s nullglob 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 for plugin_bin in "${bin_path%/*}"/plugins/*/bin; do
PATH="${plugin_bin}:${PATH}" PATH="${plugin_bin}:${PATH}"
done done

View File

@ -21,43 +21,12 @@ if [ -z "$PYENV_COMMAND" ]; then
exit 1 exit 1
fi 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) IFS=: hook_paths=($PYENV_HOOK_PATH)
shopt -s nullglob shopt -s nullglob
for path in "${hook_paths[@]}"; do for path in "${hook_paths[@]}"; do
for script in "$path/$PYENV_COMMAND"/*.bash; do for script in "$path/$PYENV_COMMAND"/*.bash; do
realpath "$script" echo "$script"
done done
done done
shopt -u nullglob shopt -u nullglob

View File

@ -25,43 +25,14 @@ for arg; do
esac esac
done done
canonicalize_dir() {
{ cd "$1" && pwd -P
} 2>/dev/null || echo "$1"
}
versions_dir="${PYENV_ROOT}/versions" 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 if [ -d "$versions_dir" ]; then
versions_dir="$(realpath "$versions_dir")" versions_dir="$(canonicalize_dir "$versions_dir")"
fi fi
if ((${BASH_VERSINFO[0]} > 3)); then if ((${BASH_VERSINFO[0]} > 3)); then
@ -138,7 +109,7 @@ fi
for path in "${versions_dir_entries[@]}"; do for path in "${versions_dir_entries[@]}"; do
if [ -d "$path" ]; then if [ -d "$path" ]; then
if [ -n "$skip_aliases" ] && [ -L "$path" ]; then if [ -n "$skip_aliases" ] && [ -L "$path" ]; then
target="$(realpath "$path")" target="$(canonicalize_dir "$path")"
[ "${target%/*}" != "$versions_dir" ] || continue [ "${target%/*}" != "$versions_dir" ] || continue
[ "${target%/*/envs/*}" != "$versions_dir" ] || continue [ "${target%/*/envs/*}" != "$versions_dir" ] || continue
fi fi