diff --git a/libexec/rbenv-rehash b/libexec/rbenv-rehash index b220329a..5ec195ec 100755 --- a/libexec/rbenv-rehash +++ b/libexec/rbenv-rehash @@ -82,9 +82,9 @@ remove_outdated_shims() { # registered for installation as a shim. In this way, plugins may call # `make_shims` with a glob to register many shims at once. make_shims() { - local shims="$@" + local shims=("$@") - for file in $shims; do + for file in "${shims[@]}"; do local shim="${file##*/}" register_shim "$shim" done diff --git a/test/rehash.bats b/test/rehash.bats index afcc11cd..97414410 100755 --- a/test/rehash.bats +++ b/test/rehash.bats @@ -53,6 +53,38 @@ ruby OUT } +@test "removes stale shims" { + mkdir -p "${RBENV_ROOT}/shims" + touch "${RBENV_ROOT}/shims/oldshim1" + chmod +x "${RBENV_ROOT}/shims/oldshim1" + + create_executable "2.0" "rake" + create_executable "2.0" "ruby" + + run rbenv-rehash + assert_success "" + + assert [ ! -e "${RBENV_ROOT}/shims/oldshim1" ] +} + +@test "binary install locations containing spaces" { + create_executable "dirname1 p247" "ruby" + create_executable "dirname2 preview1" "rspec" + + assert [ ! -e "${RBENV_ROOT}/shims/ruby" ] + assert [ ! -e "${RBENV_ROOT}/shims/rspec" ] + + run rbenv-rehash + assert_success "" + + run ls "${RBENV_ROOT}/shims" + assert_success + assert_output <