diff --git a/libexec/rbenv-rehash b/libexec/rbenv-rehash index a1d79864..9e59ddfc 100755 --- a/libexec/rbenv-rehash +++ b/libexec/rbenv-rehash @@ -37,12 +37,41 @@ create_prototype_shim() { cat > "$PROTOTYPE_SHIM_PATH" </dev/null 2>&1; then + for shim in *; do rm -f "$shim"; done + fi + break + done +} + # The basename of each argument passed to `make_shims` will be # registered for installation as a shim. In this way, plugins may call # `make_shims` with a glob to register many shims at once. @@ -97,10 +126,11 @@ remove_stale_shims() { # Change to the shims directory. cd "$SHIM_PATH" +shopt -s nullglob # Create the prototype shim, then register shims for all known binaries. create_prototype_shim -shopt -s nullglob +remove_outdated_shims make_shims ../versions/*/bin/* # Restore the previous working directory. diff --git a/libexec/rbenv-version-file b/libexec/rbenv-version-file index 9b678769..e9451f42 100755 --- a/libexec/rbenv-version-file +++ b/libexec/rbenv-version-file @@ -2,14 +2,19 @@ set -e [ -n "$RBENV_DEBUG" ] && set -x -root="$RBENV_DIR" -while [ -n "$root" ]; do - if [ -e "${root}/.rbenv-version" ]; then - echo "${root}/.rbenv-version" - exit - fi - root="${root%/*}" -done +find_local_version_file() { + local root="$1" + while [ -n "$root" ]; do + if [ -e "${root}/.rbenv-version" ]; then + echo "${root}/.rbenv-version" + exit + fi + root="${root%/*}" + done +} + +find_local_version_file "$RBENV_DIR" +[ "$RBENV_DIR" = "$PWD" ] || find_local_version_file "$PWD" global_version_file="${RBENV_ROOT}/version"