Skip to content
Draft
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
17 changes: 12 additions & 5 deletions share/chruby/chruby.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
CHRUBY_VERSION="0.3.9"
RUBIES=()
RUBIES=""

for dir in "$PREFIX/opt/rubies" "$HOME/.rubies"; do
[[ -d "$dir" && -n "$(command ls -A "$dir")" ]] && RUBIES+=("$dir"/*)
if [[ -d "$dir" && -n "$(command ls -A "$dir")" ]]; then
for ruby in "$dir"/*; do
RUBIES="${RUBIES:+$RUBIES:}$ruby"
done
fi
done
unset dir
unset dir ruby
export RUBIES

function chruby_reset()
{
Expand Down Expand Up @@ -71,7 +76,8 @@ function chruby()
;;
"")
local dir ruby
for dir in "${RUBIES[@]}"; do
local IFS=:
for dir in $RUBIES; do
dir="${dir%%/}"; ruby="${dir##*/}"
if [[ "$dir" == "$RUBY_ROOT" ]]; then
echo " * ${ruby} ${RUBYOPT}"
Expand All @@ -84,7 +90,8 @@ function chruby()
system) chruby_reset ;;
*)
local dir ruby match
for dir in "${RUBIES[@]}"; do
local IFS=:
for dir in $RUBIES; do
dir="${dir%%/}"; ruby="${dir##*/}"
case "$ruby" in
"$1") match="$dir" && break ;;
Expand Down
Loading