fix rehash when paths have spaces in them

fixes #450
This commit is contained in:
Jeffrey 'jf' Lim 2013-09-23 14:16:15 +08:00 committed by Mislav Marohnić
parent bdcc2e1790
commit caa4a8e228
2 changed files with 34 additions and 2 deletions

View file

@ -82,9 +82,9 @@ remove_outdated_shims() {
# registered for installation as a shim. In this way, plugins may call # 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` with a glob to register many shims at once.
make_shims() { make_shims() {
local shims="$@" local shims=("$@")
for file in $shims; do for file in "${shims[@]}"; do
local shim="${file##*/}" local shim="${file##*/}"
register_shim "$shim" register_shim "$shim"
done done

View file

@ -53,6 +53,38 @@ ruby
OUT 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 <<OUT
rspec
ruby
OUT
}
@test "carries original IFS within hooks" { @test "carries original IFS within hooks" {
hook_path="${RBENV_TEST_DIR}/rbenv.d" hook_path="${RBENV_TEST_DIR}/rbenv.d"
mkdir -p "${hook_path}/rehash" mkdir -p "${hook_path}/rehash"