diff --git a/libexec/rbenv-hooks b/libexec/rbenv-hooks index 201c91da..6291e78a 100755 --- a/libexec/rbenv-hooks +++ b/libexec/rbenv-hooks @@ -35,16 +35,17 @@ resolve_link() { } realpath() { - local cwd="$(pwd)" + local cwd="$PWD" local path="$1" + local name while [ -n "$path" ]; do - cd "${path%/*}" - local name="${path##*/}" + name="${path##*/}" + [ "$name" = "$path" ] || cd "${path%/*}" path="$(resolve_link "$name" || true)" done - echo "$(pwd)/$name" + echo "${PWD}/$name" cd "$cwd" } fi diff --git a/test/hooks.bats b/test/hooks.bats index 0b53d430..99dc4bf0 100644 --- a/test/hooks.bats +++ b/test/hooks.bats @@ -59,7 +59,13 @@ OUT mkdir -p "$HOME" touch "${HOME}/hola.bash" ln -s "../../home/hola.bash" "${path}/exec/hello.bash" + touch "${path}/exec/bright.sh" + ln -s "bright.sh" "${path}/exec/world.bash" RBENV_HOOK_PATH="$path" run rbenv-hooks exec - assert_success "${HOME}/hola.bash" + assert_success + assert_output <