mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-14 20:39:55 -05:00
Stop using abs_dirname()
in rbenv-init
It's slow and not necessary since we expect `$0` to already be expanded. In tests this change forces us to deal with some relative paths, but it's not a big deal. The `rbenv init -` output in the most common case will be the same as before: source '/home/myuser/.rbenv/libexec/../completions/rbenv.bash'
This commit is contained in:
parent
5287e2ebf4
commit
8bac958994
2 changed files with 3 additions and 27 deletions
|
@ -28,31 +28,7 @@ if [ -z "$shell" ]; then
|
|||
shell="$(basename "${shell:-$SHELL}")"
|
||||
fi
|
||||
|
||||
READLINK=$(type -p greadlink readlink | head -1)
|
||||
if [ -z "$READLINK" ]; then
|
||||
echo "rbenv: cannot find readlink - are you missing GNU coreutils?" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
resolve_link() {
|
||||
$READLINK "$1"
|
||||
}
|
||||
|
||||
abs_dirname() {
|
||||
local cwd="$(pwd)"
|
||||
local path="$1"
|
||||
|
||||
while [ -n "$path" ]; do
|
||||
cd "${path%/*}"
|
||||
local name="${path##*/}"
|
||||
path="$(resolve_link "$name" || true)"
|
||||
done
|
||||
|
||||
pwd
|
||||
cd "$cwd"
|
||||
}
|
||||
|
||||
root="$(abs_dirname "$0")/.."
|
||||
root="${0%/*}/.."
|
||||
|
||||
if [ -z "$print" ]; then
|
||||
case "$shell" in
|
||||
|
|
|
@ -21,7 +21,7 @@ load test_helper
|
|||
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
||||
run rbenv-init - bash
|
||||
assert_success
|
||||
assert_line "source '${root}/libexec/../completions/rbenv.bash'"
|
||||
assert_line "source '${root}/test/../libexec/../completions/rbenv.bash'"
|
||||
}
|
||||
|
||||
@test "detect parent shell" {
|
||||
|
@ -35,7 +35,7 @@ load test_helper
|
|||
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
||||
run rbenv-init - fish
|
||||
assert_success
|
||||
assert_line ". '${root}/libexec/../completions/rbenv.fish'"
|
||||
assert_line ". '${root}/test/../libexec/../completions/rbenv.fish'"
|
||||
}
|
||||
|
||||
@test "fish instructions" {
|
||||
|
|
Loading…
Reference in a new issue