-
Notifications
You must be signed in to change notification settings - Fork 0
/
xvm.source.bash
56 lines (41 loc) · 1.14 KB
/
xvm.source.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
function xvm_chruby {
local version
if { read -r version < .ruby-version; } 2>/dev/null || [[ -n "$version" ]]; then
version="${version%%[[:space:]]}"
if [ "$version" == "$XVM_CHRUBY" ]; then
return 0
fi
type chruby >/dev/null || return 1;
echo "xvm: calling chruby $version"
chruby "$version" && XVM_CHRUBY="$version"
fi
}
function xvm_evm {
local version
if { read -r version < .xvm-evm; } 2>/dev/null || [[ -n "$version" ]]; then
if [ "$version" == "$XVM_EVM" ]; then
return 0
fi
type evm >/dev/null || return 1;
echo "xvm: calling evm use $version"
evm use "$version" && XVM_EVM="$version"
fi
}
function xvm_kiex {
local version
if { read -r version < .xvm-kiex; } 2>/dev/null || [[ -n "$version" ]]; then
if [ "$version" == "$XVM_KIEX" ]; then
return 0
fi
type kiex >/dev/null || return 1;
echo "xvm: calling kiex use $version"
kiex use "$version" && XVM_KIEX="$version"
fi
}
function xvm {
local failed
xvm_chruby || failed=true
# calling kiex only makes sense after evm was a success
xvm_evm && xvm_kiex || failed=true
[ -z $failed ]
}