Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow a prefix path for easier binstubs #444

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions share/chruby/chruby.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function chruby_reset()
[[ -z "$RUBY_ROOT" ]] && return

PATH=":$PATH:"; PATH="${PATH//:$RUBY_ROOT\/bin:/:}"
[[ -n "$RUBY_PREPEND" ]] && PATH="${PATH//:$RUBY_PREPEND:/:}"
[[ -n "$GEM_ROOT" ]] && PATH="${PATH//:$GEM_ROOT\/bin:/:}"

if (( UID != 0 )); then
Expand All @@ -30,6 +31,15 @@ function chruby_reset()
hash -r
}

function chruby_prepend()
{
if [[ -n "$RUBY_PREPEND" ]]; then
PATH=":$PATH:"; PATH="${PATH//:$RUBY_PREPEND:/:}"
fi
export RUBY_PREPEND="$1"
[[ -n "$RUBY_ROOT" ]] && chruby_use "$RUBY_ROOT" "$RUBYOPT"
}

function chruby_use()
{
if [[ ! -x "$1/bin/ruby" ]]; then
Expand All @@ -56,6 +66,10 @@ EOF
export GEM_PATH="$GEM_HOME${GEM_ROOT:+:$GEM_ROOT}${GEM_PATH:+:$GEM_PATH}"
export PATH="$GEM_HOME/bin:$PATH"
fi

if [[ -n "$RUBY_PREPEND" ]]; then
export PATH="$RUBY_PREPEND:$PATH"
fi

hash -r
}
Expand Down