-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrvm-shell
executable file
·34 lines (30 loc) · 969 Bytes
/
rvm-shell
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
#!/usr/bin/env bash
__rvm_shell_lookup_script() {
local relative_scripts_dir="$(dirname -- "$(dirname -- "$0")")/scripts"
for directory in "$rvm_scripts_path" "$HOME/.rvm/scripts" "/usr/local/rvm/scripts" "$relative_scripts_dir"; do
if [[ -d "$directory" && -s "$directory/rvm" ]]; then
echo "$directory/rvm"
return
fi
done
}
# If the first argument isn't -c, remove it and set it to the ruby string value.
if [[ -n "$1" && ! -f "$1" && -n "$(echo "$1" | \grep -v '^-')" ]]; then
rvm_shell_ruby_string="$1"
shift
fi
rvm_shell_rvm_path="$(__rvm_shell_lookup_script)"
if [[ -n "$rvm_shell_rvm_path" ]]; then
source "$rvm_shell_rvm_path"
# Setup as expected.
if [[ -n "$rvm_shell_ruby_string" ]]; then
rvm "$rvm_shell_ruby_string"
if [[ "$?" -gt 0 ]]; then
echo "Error: RVM was unable to use '$rvm_shell_ruby_string'" 1>&2
exit 1
fi
else
rvm rvmrc load >/dev/null 2>&1
fi
fi
exec bash "$@"