From bdcc2e179008e6060a95412c67a9e3abdc7f24f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Mon, 9 Sep 2013 09:53:29 +0200 Subject: [PATCH] check if completion script is readable fixes #444 --- libexec/rbenv-init | 7 ++----- test/init.bats | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/libexec/rbenv-init b/libexec/rbenv-init index 7fb7b737..2dbd67d1 100755 --- a/libexec/rbenv-init +++ b/libexec/rbenv-init @@ -83,11 +83,8 @@ if [[ ":${PATH}:" != *:"${RBENV_ROOT}/shims":* ]]; then echo 'export PATH="'${RBENV_ROOT}'/shims:${PATH}"' fi -case "$shell" in -bash | zsh ) - echo "source \"$root/completions/rbenv.${shell}\"" - ;; -esac +completion="${root}/completions/rbenv.${shell}" +[ -r "$completion" ] && echo "source '$completion'" if [ -z "$no_rehash" ]; then echo 'rbenv rehash 2>/dev/null' diff --git a/test/init.bats b/test/init.bats index 95781e33..dc9fe302 100644 --- a/test/init.bats +++ b/test/init.bats @@ -22,7 +22,7 @@ load test_helper root="$(cd $BATS_TEST_DIRNAME/.. && pwd)" run rbenv-init - assert_success - assert_line 'source "'${root}'/libexec/../completions/rbenv.bash"' + assert_line "source '${root}/libexec/../completions/rbenv.bash'" } @test "option to skip rehash" {