/
rvm
executable file
·126 lines (86 loc) · 3.15 KB
/
rvm
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env bash
# rvm : Ruby enVironment Manager
# http://rvm.beginrescueend.com
# http://github.com/wayneeseguin/rvm
# Is RVM loaded as a shell function already?
export HOME="${HOME%%+(\/)}" # Remove trailing slashes if they exist on HOME
if [[ ${rvm_ignore_rvmrc:-0} -eq 0 ]]; then
for rvmrc in /etc/rvmrc "$HOME/.rvmrc" ; do
if [[ -f "$rvmrc" ]] ; then
if \grep -q '^\s*rvm .*$' $rvmrc ; then
printf "\nError: $rvmrc is for rvm settings only.\nrvm CLI may NOT be called from within $rvmrc. \nSkipping the loading of $rvmrc"
return 1
else
source "$rvmrc"
fi
fi
done
fi
if [[ -z "${rvm_path:-}" ]] ; then
# Set the default sandboxed value.
# TODO: Alter the variable names to make sense
if [[ -z "${rvm_user_install:-""}" ]]; then
if [[ $UID -eq 0 || -n "$rvm_prefix" && "$rvm_prefix" != "$HOME"/* ]]; then
rvm_user_install=0
else
rvm_user_install=1
fi
fi
if [[ -z "${rvm_prefix:-""}" ]] ; then
if [[ "${rvm_user_install:-0}" = "0" ]] ; then
rvm_prefix="/usr/local/"
elif [[ -n "$HOME" ]] ; then
rvm_prefix="$HOME/."
else
echo "No \$rvm_prefix was provided and "
echo "$(id | \sed -e's/^[^(]*(//' -e 's/).*//') has no \$HOME defined."
echo "Haling loading of RVM."
rvm_load_rvm=0
fi
fi
# Fix rvm_prefix changes.
[[ "${rvm_prefix}" != *[/.] && -d "${rvm_prefix/rvm/scripts}" ]]
rvm_prefix_needs_trailing_slash="$?"
if [[ "$rvm_prefix" = "/usr/local" || "$rvm_prefix_needs_trailing_slash" = "0" ]]; then
rvm_prefix="$rvm_prefix/"
fi
if [[ -z "${rvm_path:-""}" ]] ; then
rvm_path="${rvm_prefix}rvm"
fi
export rvm_path="${rvm_path%%+(\/)}"
fi
if ! declare -f rvm > /dev/null || [[ ${rvm_reload_flag:-0} -eq 1 ]] ; then
if [[ -n "${rvm_path}" && -d "$rvm_path" ]] ; then
true ${rvm_scripts_path:="$rvm_path/scripts"}
if [[ ${rvm_load_rvm:-1} -eq 1 ]] ; then
for script in base version selector cd cli override_gem ; do
if [[ -f "$rvm_scripts_path/$script" ]] ; then
source "$rvm_scripts_path/$script"
else
printf "WARNING: Could not source script '$rvm_scripts_path/$script', file does not exist. RVM will likely not work as expected.\n"
fi
done
rvm_version="$(cat "$rvm_path/VERSION")"
export rvm_version="${rvm_version/%.}"
alias rvm-restart="source '${rvm_path}/scripts/rvm'"
if ! command -v ruby >/dev/null 2>&1 || command -v ruby | \grep -v rvm >/dev/null ; then
[[ -s "$rvm_environments_path/default" ]] &&
source "$rvm_environments_path/default"
fi
# Makes sure rvm_bin_path is in PATH atleast once.
__rvm_conditionally_add_bin_path
else
printf "\n\$rvm_path ($rvm_path) does not exist."
fi
fi
unset rvm_prefix_needs_trailing_slash rvm_rc_files rvm_gems_cache_path rvm_gems_path rvm_project_rvmrc_default rvm_gemset_separator
fi
case $- in
*i*)
if [[ "screen" = $TERM ]]; then
# Reload the rvmrc, use promptless ensuring shell processes does not
# prompt if .rvmrc trust value is not stored.
rvm_promptless=1 __rvm_project_rvmrc
fi
;;
esac