Skip to content

Commit 6c1e3ec

Browse files
committed
move ruby discovery code into a function
When you install a new ruby in a different terminal shell, chruby does not pick up on the new ruby version. The solution is to to source chruby.sh again. Introducing chruby_discover which will allow any shell to pick up on the new ruby versions
1 parent a543a35 commit 6c1e3ec

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

share/chruby/chruby.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
CHRUBY_VERSION="0.3.9"
2-
RUBIES=()
32

4-
for dir in "$PREFIX/opt/rubies" "$HOME/.rubies"; do
5-
[[ -d "$dir" && -n "$(command ls -A "$dir")" ]] && RUBIES+=("$dir"/*)
6-
done
7-
unset dir
3+
function chruby_discover()
4+
{
5+
RUBIES=()
6+
local dir
7+
for dir in "$PREFIX/opt/rubies" "$HOME/.rubies"; do
8+
[[ -d "$dir" && -n "$(command ls -A "$dir")" ]] && RUBIES+=("$dir"/*)
9+
done
10+
}
811

912
function chruby_reset()
1013
{
@@ -102,3 +105,5 @@ function chruby()
102105
;;
103106
esac
104107
}
108+
109+
chruby_discover

0 commit comments

Comments
 (0)