cleanup in fish
Use process subtitution syntax: . (rbenv init -|psub) instead of: eval (rbenv init -) because the latter doesn't work well with newlines.
This commit is contained in:
parent
5bfec84432
commit
31fab8cdae
@ -73,7 +73,14 @@ if [ -z "$print" ]; then
|
|||||||
{ echo "# Load rbenv automatically by adding"
|
{ echo "# Load rbenv automatically by adding"
|
||||||
echo "# the following to ${profile}:"
|
echo "# the following to ${profile}:"
|
||||||
echo
|
echo
|
||||||
echo 'eval "$(rbenv init -)"'
|
case "$shell" in
|
||||||
|
fish )
|
||||||
|
echo '. (rbenv init -|psub)'
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo 'eval "$(rbenv init -)"'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
echo
|
echo
|
||||||
} >&2
|
} >&2
|
||||||
|
|
||||||
@ -85,7 +92,7 @@ mkdir -p "${RBENV_ROOT}/"{shims,versions}
|
|||||||
if [[ ":${PATH}:" != *:"${RBENV_ROOT}/shims":* ]]; then
|
if [[ ":${PATH}:" != *:"${RBENV_ROOT}/shims":* ]]; then
|
||||||
case "$shell" in
|
case "$shell" in
|
||||||
fish )
|
fish )
|
||||||
echo 'setenv PATH "'${RBENV_ROOT}'/shims"' '$PATH' ';'
|
echo "setenv PATH '${RBENV_ROOT}/shims' \$PATH"
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
echo 'export PATH="'${RBENV_ROOT}'/shims:${PATH}"'
|
echo 'export PATH="'${RBENV_ROOT}'/shims:${PATH}"'
|
||||||
@ -94,7 +101,7 @@ if [[ ":${PATH}:" != *:"${RBENV_ROOT}/shims":* ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
completion="${root}/completions/rbenv.${shell}"
|
completion="${root}/completions/rbenv.${shell}"
|
||||||
[ -r "$completion" ] && echo "source '$completion'"
|
[ -r "$completion" ] && echo ". '$completion'"
|
||||||
|
|
||||||
if [ -z "$no_rehash" ]; then
|
if [ -z "$no_rehash" ]; then
|
||||||
echo 'rbenv rehash 2>/dev/null'
|
echo 'rbenv rehash 2>/dev/null'
|
||||||
@ -106,9 +113,7 @@ fish )
|
|||||||
cat <<EOS
|
cat <<EOS
|
||||||
function rbenv
|
function rbenv
|
||||||
set command \$argv[1]
|
set command \$argv[1]
|
||||||
if [ (count \$argv) -gt 0 ]
|
set -e argv[1]
|
||||||
set -e argv[1]
|
|
||||||
end
|
|
||||||
|
|
||||||
switch "\$command"
|
switch "\$command"
|
||||||
case ${commands[*]}
|
case ${commands[*]}
|
||||||
|
@ -15,9 +15,11 @@ rbenv-rehash
|
|||||||
|
|
||||||
case "$shell" in
|
case "$shell" in
|
||||||
fish )
|
fish )
|
||||||
# nothing to do
|
or='; or'
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
echo "hash -r 2>/dev/null || true"
|
or='||'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
echo "hash -r 2>/dev/null $or true"
|
||||||
|
@ -21,14 +21,14 @@ load test_helper
|
|||||||
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
||||||
SHELL=/bin/bash run rbenv-init -
|
SHELL=/bin/bash run rbenv-init -
|
||||||
assert_success
|
assert_success
|
||||||
assert_line "source '${root}/libexec/../completions/rbenv.bash'"
|
assert_line ". '${root}/libexec/../completions/rbenv.bash'"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "setup shell completions (fish)" {
|
@test "setup shell completions (fish)" {
|
||||||
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
||||||
SHELL=/usr/bin/fish run rbenv-init -
|
SHELL=/usr/bin/fish run rbenv-init -
|
||||||
assert_success
|
assert_success
|
||||||
assert_line '. "'${root}'/libexec/../completions/rbenv.fish";'
|
assert_line ". '${root}/libexec/../completions/rbenv.fish'"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "option to skip rehash" {
|
@test "option to skip rehash" {
|
||||||
@ -48,7 +48,7 @@ load test_helper
|
|||||||
export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin"
|
export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin"
|
||||||
SHELL=/usr/bin/fish run rbenv-init -
|
SHELL=/usr/bin/fish run rbenv-init -
|
||||||
assert_success
|
assert_success
|
||||||
assert_line 0 'setenv PATH "'${RBENV_ROOT}'/shims" $PATH ;'
|
assert_line 0 "setenv PATH '${RBENV_ROOT}/shims' \$PATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "doesn't add shims to PATH more than once" {
|
@test "doesn't add shims to PATH more than once" {
|
||||||
|
@ -98,3 +98,17 @@ SH
|
|||||||
assert_success
|
assert_success
|
||||||
assert_output "HELLO=:hello:ugly:world:again"
|
assert_output "HELLO=:hello:ugly:world:again"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "sh-rehash in bash" {
|
||||||
|
create_executable "2.0" "ruby"
|
||||||
|
SHELL=/bin/bash run rbenv-sh-rehash
|
||||||
|
assert_success "hash -r 2>/dev/null || true"
|
||||||
|
assert [ -x "${RBENV_ROOT}/shims/ruby" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "sh-rehash in fish" {
|
||||||
|
create_executable "2.0" "ruby"
|
||||||
|
SHELL=/usr/bin/fish run rbenv-sh-rehash
|
||||||
|
assert_success "hash -r 2>/dev/null ; or true"
|
||||||
|
assert [ -x "${RBENV_ROOT}/shims/ruby" ]
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user