Use absolute path in rbenv init instructions if needed

This commit is contained in:
Mislav Marohnić 2022-09-25 22:32:46 +02:00
parent 33f8621ec8
commit 6426f852d0
No known key found for this signature in database

View file

@ -45,6 +45,11 @@ root="${BASH_SOURCE:-$0}"
root="${root%/*}" root="${root%/*}"
root="${root%/*}" root="${root%/*}"
rbenv_in_path=true
if [ -n "$RBENV_ORIG_PATH" ]; then
PATH="$RBENV_ORIG_PATH" command -v rbenv >/dev/null || rbenv_in_path=""
fi
if [ -z "$print" ]; then if [ -z "$print" ]; then
case "$shell" in case "$shell" in
bash ) bash )
@ -68,18 +73,27 @@ if [ -z "$print" ]; then
;; ;;
esac esac
{ echo "# Load rbenv automatically by appending" rbenv_command=rbenv
echo "# the following to ${profile}:" if [ -z "$rbenv_in_path" ]; then
rbenv_command="$root/bin/rbenv"
rbenv_command="${rbenv_command/$HOME\//~/}"
fi
{ echo "# Please add the following line to your \`${profile}' file,"
echo "# then restart your terminal."
echo echo
[ -t 2 ] && printf '\e[33;1m'
case "$shell" in case "$shell" in
fish ) fish )
echo 'status --is-interactive; and rbenv init - fish | source' printf 'status --is-interactive; and %s init - fish | source' "$rbenv_command"
;; ;;
* ) * )
# shellcheck disable=SC2016 # shellcheck disable=SC2016
printf 'eval "$(rbenv init - %s)"\n' "$shell" printf 'eval "$(%s init - %s)"' "$rbenv_command" "$shell"
;; ;;
esac esac
[ -t 2 ] && printf '\e[m'
echo
echo echo
} >&2 } >&2
@ -88,11 +102,6 @@ fi
mkdir -p "${RBENV_ROOT}/"{shims,versions} mkdir -p "${RBENV_ROOT}/"{shims,versions}
rbenv_in_path=true
if [ -n "$RBENV_ORIG_PATH" ]; then
PATH="$RBENV_ORIG_PATH" command -v rbenv >/dev/null || rbenv_in_path=""
fi
case "$shell" in case "$shell" in
fish ) fish )
[ -n "$rbenv_in_path" ] || printf "set -gx PATH '%s/bin' \$PATH\n" "$root" [ -n "$rbenv_in_path" ] || printf "set -gx PATH '%s/bin' \$PATH\n" "$root"