-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
base
executable file
·115 lines (99 loc) · 2.54 KB
/
base
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
#!/usr/bin/env bash
# Base is a collection of general files + commonly included setup functions.
#duplicated from scripts/rvm - rare reload issue
__rvm_has_opt()
{
{
[[ -n "${ZSH_VERSION}" ]] && setopt | grep "^${1}$" >/dev/null 2>&1
} ||
{
[[ -n "${BASH_VERSION}" ]] && [[ ":$SHELLOPTS:" =~ ":${1}:" ]]
} ||
return 1
}
if __rvm_has_opt "errexit"
then rvm_stored_errexit=1
fi
set +e
: rvm_trace_flag:${rvm_trace_flag:=0}
if (( rvm_trace_flag > 0 ))
then
set -o xtrace
if [[ -z "${ZSH_VERSION:-}" ]]
then
# set -o errtrace
# set -o pipefail
export PS4
PS4="+ \$(date \"+%s.%N\") \${BASH_SOURCE##\${rvm_path:-}} : \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} > "
fi
fi
export __array_start rvm_path >/dev/null
#
# Setup environment parameters.
#
if [[ -n "${ZSH_VERSION:-}" ]]
then
__array_start=1
else
__array_start=0
fi
if (( ${rvm_ignore_rvmrc:=0} == 0 ))
then
[[ -n "${rvm_stored_umask:-}" ]] || export rvm_stored_umask=$(umask)
rvm_rvmrc_files=("/etc/rvmrc" "$HOME/.rvmrc")
if [[ -n "${rvm_prefix:-}" ]] && ! [[ "$HOME/.rvmrc" -ef "${rvm_prefix}/.rvmrc" ]]
then rvm_rvmrc_files+=( "${rvm_prefix}/.rvmrc" )
fi
for rvmrc in "${rvm_rvmrc_files[@]}"
do
if [[ -f "$rvmrc" ]]
then
if GREP_OPTIONS="" \grep '^\s*rvm .*$' "$rvmrc" >/dev/null 2>&1
then
printf "%b" "
Error:
$rvmrc is for rvm settings only.
rvm CLI may NOT be called from within $rvmrc.
Skipping the loading of $rvmrc"
return 1
else
source "$rvmrc"
fi
fi
done
unset rvm_rvmrc_files
fi
export rvm_path
if [[ -z "${rvm_path:-}" ]]
then
if (( UID == 0 )) && [[ -d "/usr/local/rvm" ]]
then rvm_path="/usr/local/rvm"
elif [[ -d "${HOME}/.rvm" ]]
then rvm_path="${HOME}/.rvm"
elif [[ -d "/usr/local/rvm" ]]
then rvm_path="/usr/local/rvm"
else echo "Can't find rvm install!" 1>&2 ; exit 1
fi
fi
true ${rvm_scripts_path:="$rvm_path/scripts"}
# Initialize all main RVM variables.
source "$rvm_scripts_path/initialize"
# Load the general scripts.
# Use rvm_base_except="selector", for example, to override the loading.
case " ${rvm_base_except:-} " in
(*[[:space:]]selector[[:space:]]*)
true # do not load.
;;
(*)
source "$rvm_scripts_path/selector"
source "$rvm_scripts_path/selector_gemsets"
;;
esac
typeset -a scripts
scripts=(
logging support utility init cleanup env rvmrc install environment gemset db checksum
)
for entry in ${scripts[@]} ; do
source "$rvm_scripts_path/functions/$entry"
done
unset scripts entry rvm_base_except