From e97326845cfff40099c2cb47a7b79954f655386a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 3 Oct 2013 16:12:24 +0200 Subject: [PATCH] Ubuntu fix: don't use `.` in place of `source` If `rbenv init -` outputs `.` in place of `source` and that gets eval'd by the desktop manager via `~/.profile`, it chokes and prevents the user from logging in. Fixes #457 --- libexec/rbenv-init | 7 ++++++- test/init.bats | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libexec/rbenv-init b/libexec/rbenv-init index 1a2762c7..22d509bc 100755 --- a/libexec/rbenv-init +++ b/libexec/rbenv-init @@ -101,7 +101,12 @@ if [[ ":${PATH}:" != *:"${RBENV_ROOT}/shims":* ]]; then fi completion="${root}/completions/rbenv.${shell}" -[ -r "$completion" ] && echo ". '$completion'" +if [ -r "$completion" ]; then + case "$shell" in + fish ) echo ". '$completion'" ;; + * ) echo "source '$completion'" ;; + esac +fi if [ -z "$no_rehash" ]; then echo 'rbenv rehash 2>/dev/null' diff --git a/test/init.bats b/test/init.bats index d0795eef..38771ef9 100644 --- a/test/init.bats +++ b/test/init.bats @@ -21,7 +21,7 @@ load test_helper root="$(cd $BATS_TEST_DIRNAME/.. && pwd)" SHELL=/bin/bash run rbenv-init - assert_success - assert_line ". '${root}/libexec/../completions/rbenv.bash'" + assert_line "source '${root}/libexec/../completions/rbenv.bash'" } @test "setup shell completions (fish)" {