rvm 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/VERSION.yml +1 -1
- data/lib/rvm/environment.rb +1 -1
- data/lib/rvm/shell/shell_wrapper.sh +1 -1
- data/rvm.gemspec +3 -110
- metadata +4 -111
- data/binscripts/rvm +0 -76
- data/binscripts/rvm-auto-ruby +0 -24
- data/binscripts/rvm-prompt +0 -208
- data/binscripts/rvm-shell +0 -35
- data/binscripts/rvm-update-head +0 -58
- data/binscripts/rvm-update-latest +0 -27
- data/binscripts/rvmsudo +0 -20
- data/config/db +0 -71
- data/config/known +0 -54
- data/config/md5 +0 -139
- data/contrib/gemset_snapshot +0 -25
- data/contrib/install-system-wide +0 -221
- data/contrib/r +0 -44
- data/examples/rvmrc +0 -49
- data/gemsets/default.gems +0 -1
- data/gemsets/global.gems +0 -1
- data/help/alias +0 -46
- data/help/benchmark +0 -17
- data/help/cleanup +0 -23
- data/help/debug +0 -8
- data/help/disk-usage +0 -15
- data/help/docs +0 -22
- data/help/exec +0 -33
- data/help/fetch +0 -5
- data/help/gem +0 -0
- data/help/gemdir +0 -0
- data/help/gemset +0 -14
- data/help/implode +0 -0
- data/help/info +0 -62
- data/help/install +0 -0
- data/help/list +0 -0
- data/help/migrate +0 -15
- data/help/monitor +0 -0
- data/help/notes +0 -0
- data/help/package +0 -0
- data/help/rake +0 -14
- data/help/remove +0 -0
- data/help/repair +0 -23
- data/help/reset +0 -0
- data/help/ruby +0 -84
- data/help/rubygems +0 -11
- data/help/rvmrc +0 -34
- data/help/snapshot +0 -15
- data/help/specs +0 -0
- data/help/srcdir +0 -0
- data/help/tests +0 -0
- data/help/tools +0 -22
- data/help/uninstall +0 -0
- data/help/update +0 -0
- data/help/upgrade +0 -18
- data/help/use +0 -0
- data/help/wrapper +0 -41
- data/install +0 -667
- data/man/man1/rvm.1 +0 -380
- data/man/man1/rvm.1.gz +0 -0
- data/scripts/alias +0 -226
- data/scripts/aliases +0 -4
- data/scripts/array +0 -32
- data/scripts/base +0 -57
- data/scripts/cd +0 -94
- data/scripts/cleanup +0 -58
- data/scripts/cli +0 -798
- data/scripts/color +0 -49
- data/scripts/completion +0 -151
- data/scripts/db +0 -87
- data/scripts/default +0 -64
- data/scripts/disk-usage +0 -60
- data/scripts/docs +0 -115
- data/scripts/env +0 -46
- data/scripts/environment-convertor +0 -74
- data/scripts/fetch +0 -231
- data/scripts/gemsets +0 -1045
- data/scripts/get +0 -126
- data/scripts/hash +0 -37
- data/scripts/help +0 -46
- data/scripts/hook +0 -23
- data/scripts/info +0 -213
- data/scripts/initialize +0 -29
- data/scripts/install +0 -667
- data/scripts/irbrc +0 -13
- data/scripts/irbrc.rb +0 -64
- data/scripts/list +0 -315
- data/scripts/log +0 -38
- data/scripts/maglev +0 -193
- data/scripts/manage +0 -2157
- data/scripts/match +0 -6
- data/scripts/md5 +0 -22
- data/scripts/migrate +0 -175
- data/scripts/monitor +0 -105
- data/scripts/notes +0 -140
- data/scripts/override_gem +0 -14
- data/scripts/package +0 -302
- data/scripts/patches +0 -64
- data/scripts/patchsets +0 -87
- data/scripts/repair +0 -199
- data/scripts/rubygems +0 -157
- data/scripts/rvm +0 -128
- data/scripts/rvm-install +0 -667
- data/scripts/selector +0 -904
- data/scripts/set +0 -301
- data/scripts/snapshot +0 -262
- data/scripts/tools +0 -58
- data/scripts/update +0 -667
- data/scripts/upgrade +0 -144
- data/scripts/utility +0 -1499
- data/scripts/version +0 -17
- data/scripts/wrapper +0 -210
data/scripts/upgrade
DELETED
@@ -1,144 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
unset GREP_OPTIONS
|
4
|
-
source "$rvm_path/scripts/base"
|
5
|
-
|
6
|
-
usage()
|
7
|
-
{
|
8
|
-
printf "
|
9
|
-
|
10
|
-
Usage:
|
11
|
-
|
12
|
-
rvm upgrade [new ruby] [existing ruby]
|
13
|
-
|
14
|
-
Description:
|
15
|
-
|
16
|
-
Upgrades the latest installed ruby with a given ruby string
|
17
|
-
(e.g. ree) to the latest known version or the version specified
|
18
|
-
|
19
|
-
"
|
20
|
-
}
|
21
|
-
|
22
|
-
confirm()
|
23
|
-
{
|
24
|
-
|
25
|
-
local confirmation_response
|
26
|
-
|
27
|
-
printf "$1 (Y/n): "
|
28
|
-
|
29
|
-
read -r confirmation_response
|
30
|
-
|
31
|
-
if [[ -n "$confirmation_response" ]] ; then
|
32
|
-
echo $confirmation_response | \grep -qi '^y\|^Y'
|
33
|
-
fi
|
34
|
-
}
|
35
|
-
|
36
|
-
die_with_error()
|
37
|
-
{
|
38
|
-
"$rvm_path/scripts/log" "fail" "$1"
|
39
|
-
exit "${2:-1}"
|
40
|
-
}
|
41
|
-
|
42
|
-
expand_ruby_name()
|
43
|
-
{
|
44
|
-
"$rvm_path/scripts/tools" strings "$1" \
|
45
|
-
| awk -F"${rvm_gemset_separator:-"@"}" '{print $1}'
|
46
|
-
}
|
47
|
-
|
48
|
-
expand_existing_ruby()
|
49
|
-
{
|
50
|
-
local prefix ruby_name
|
51
|
-
|
52
|
-
prefix="$(expand_ruby_name "$1" | awk -F'-' '{print $1"-"$2}')"
|
53
|
-
|
54
|
-
while read -r ruby_name; do
|
55
|
-
|
56
|
-
if [[ "$ruby_name" != "$expanded_destination"* ]]; then
|
57
|
-
echo "$ruby_name" ; return 0
|
58
|
-
fi
|
59
|
-
|
60
|
-
done < <("$rvm_path/scripts/list" strings | tr ' ' '\n' \
|
61
|
-
| sort -ur | \grep "^$prefix" | \grep -v '-head$' | head -n1)
|
62
|
-
|
63
|
-
return 1
|
64
|
-
}
|
65
|
-
|
66
|
-
upgrade_ruby()
|
67
|
-
{
|
68
|
-
|
69
|
-
if [[ -z "$source_ruby" ]] ; then
|
70
|
-
die_with_error "Unable to find a source ruby. Please manually provide one."
|
71
|
-
fi
|
72
|
-
|
73
|
-
expanded_source="$(expand_ruby_name "$source_ruby")"
|
74
|
-
|
75
|
-
if [[ -z "$expanded_source" ]] ; then
|
76
|
-
die_with_error "The source ruby was not a valid ruby string."
|
77
|
-
fi
|
78
|
-
|
79
|
-
if ! confirm "Are you sure you wish to upgrade from $expanded_source to \
|
80
|
-
$expanded_destination?" ; then
|
81
|
-
die_with_error "Cancelling upgrade."
|
82
|
-
fi
|
83
|
-
|
84
|
-
if [[ ! -d "$rvm_path/rubies/$expanded_destination" ]]; then
|
85
|
-
|
86
|
-
"$rvm_path/scripts/log" "info" \
|
87
|
-
"Installing new ruby $expanded_destination"
|
88
|
-
|
89
|
-
"${rvm_bin_path:-"$rvm_path/bin"}/rvm" install "$expanded_destination"
|
90
|
-
|
91
|
-
result="$?"
|
92
|
-
|
93
|
-
if [[ "$result" -gt 0 ]] ; then
|
94
|
-
die_with_error "Unable to install ruby $expanded_destination. \
|
95
|
-
Please install it manually to continue." "$result"
|
96
|
-
fi
|
97
|
-
|
98
|
-
fi
|
99
|
-
|
100
|
-
"$rvm_path/scripts/log" "info" \
|
101
|
-
"Migrating gems from $expanded_source to $expanded_destination"
|
102
|
-
|
103
|
-
"$rvm_path/scripts/migrate" "$expanded_source" "$expanded_destination"
|
104
|
-
result="$?"
|
105
|
-
|
106
|
-
[[ "$result" -gt 0 ]] && die_with_error "Error migrating gems." "$result"
|
107
|
-
|
108
|
-
"$rvm_path/scripts/log" "info" "Upgrade complete!"
|
109
|
-
}
|
110
|
-
|
111
|
-
args=($*)
|
112
|
-
destination_ruby="${args[$__array_start]}"
|
113
|
-
args[$__array_start]=""
|
114
|
-
args=(${args[@]})
|
115
|
-
|
116
|
-
source_ruby="${args[$__array_start]:-"$(expand_existing_ruby "$destination_ruby")"}"
|
117
|
-
args[$__array_start]=""
|
118
|
-
args=(${args[@]})
|
119
|
-
|
120
|
-
if [[ -z "${source_ruby:-""}" ]] ; then
|
121
|
-
usage >&2
|
122
|
-
exit 1
|
123
|
-
fi
|
124
|
-
|
125
|
-
if [[ "help" = "$source_ruby" ]] ; then
|
126
|
-
usage
|
127
|
-
exit 0
|
128
|
-
fi
|
129
|
-
|
130
|
-
expanded_destination="$(expand_ruby_name "$destination_ruby")"
|
131
|
-
|
132
|
-
if [[ -z "$source_ruby" ]] ; then
|
133
|
-
die_with_error \
|
134
|
-
"Source ruby was either not a recognized ruby string or not installed."
|
135
|
-
fi
|
136
|
-
|
137
|
-
if [[ -z "$expanded_destination" ]] ; then
|
138
|
-
die_with_error \
|
139
|
-
"Destination ruby is not a known ruby string."
|
140
|
-
fi
|
141
|
-
|
142
|
-
upgrade_ruby
|
143
|
-
|
144
|
-
exit $?
|
data/scripts/utility
DELETED
@@ -1,1499 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
__rvm_setup()
|
4
|
-
{
|
5
|
-
# ZSH has 1 based array indexing, bash has 0 based.
|
6
|
-
if [[ -n "${ZSH_VERSION:-""}" ]] ; then
|
7
|
-
__shell_array_start=1
|
8
|
-
# Set clobber for zsh users, for compatibility with bash's append operator ( >> file ) behavior
|
9
|
-
setopt | \grep -qs '^noclobber$'
|
10
|
-
rvm_zsh_clobber=$?
|
11
|
-
setopt clobber
|
12
|
-
else
|
13
|
-
__shell_array_start=0 # bash array indexes are 0 based.
|
14
|
-
fi ; export __shell_array_start
|
15
|
-
}
|
16
|
-
|
17
|
-
__rvm_teardown()
|
18
|
-
{
|
19
|
-
if [[ -n "${ZSH_VERSION:-""}" ]] ; then
|
20
|
-
|
21
|
-
if [[ ${rvm_zsh_clobber:-0} -eq 0 ]] ; then
|
22
|
-
|
23
|
-
setopt noclobber
|
24
|
-
|
25
|
-
fi
|
26
|
-
|
27
|
-
unset rvm_zsh_clobber
|
28
|
-
|
29
|
-
else
|
30
|
-
: # currently we are not doing any option setting for bash.
|
31
|
-
fi
|
32
|
-
# Ruby strings are scoped to their action.
|
33
|
-
# Hence, we ensure we remove them at in
|
34
|
-
# the cleanup phase.
|
35
|
-
|
36
|
-
# Clean up after CC switch
|
37
|
-
if [[ ${rvm_clang_flag:-0} -gt 0 ]] ; then
|
38
|
-
|
39
|
-
if [[ -n "${rvm_prior_cc:-""}" ]] ; then
|
40
|
-
|
41
|
-
export CC="$rvm_prior_cc"
|
42
|
-
|
43
|
-
else
|
44
|
-
|
45
|
-
unset CC
|
46
|
-
|
47
|
-
fi
|
48
|
-
|
49
|
-
fi
|
50
|
-
|
51
|
-
unset rvm_ruby_strings rvm_head_flag rvm_prior_cc next_token rvm_bin_path rvm_error_message rvm_gems_cache_path rvm_gems_path rvm_gemset_name rvm_interactive_flag rvm_man_path rvm_parse_break rvm_rc_files rvm_ruby_binary rvm_ruby_gem_home rvm_ruby_gem_path rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_log_path rvm_ruby_major_version rvm_ruby_minor_version rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_repo_branch rvm_ruby_revision rvm_ruby_selected_flag rvm_ruby_tag rvm_ruby_version rvm_selfcontained rvm_token rvm_ruby_load_path rvm_path_flag rvm_ruby_require rvm_action rvm_ruby_package_file rvm_ruby_name
|
52
|
-
|
53
|
-
[[ ${rvm_dump_environment_flag:-0} -eq 1 ]] && __rvm_dump_environment
|
54
|
-
|
55
|
-
return 0
|
56
|
-
}
|
57
|
-
|
58
|
-
# Dump the current environment to a file.
|
59
|
-
__rvm_dump_environment()
|
60
|
-
{
|
61
|
-
# Note: This assumes that there is a ','
|
62
|
-
local dump_environment_file dump_environment_type rvm_dump_environment_flag
|
63
|
-
|
64
|
-
dump_environment_file="${rvm_dump_environment_flag/,*/}"
|
65
|
-
|
66
|
-
dump_environment_type="${rvm_dump_environment_flag/*,/}"
|
67
|
-
|
68
|
-
if [[ -n "$dump_environment_file" && -n "$dump_environment_type" ]]; then
|
69
|
-
|
70
|
-
if [[ "$dump_environment_type" == "atheis"* && -f "$dump_environment_file" ]] ; then
|
71
|
-
# TODO: Query Darcy about the ln.
|
72
|
-
\rm -f "$dump_environment_file" \
|
73
|
-
&& ln -s /dev/null "$dump_environment_file" >/dev/null 2>&1
|
74
|
-
|
75
|
-
else
|
76
|
-
"$rvm_path/scripts/environment-convertor" "$dump_environment_type" \
|
77
|
-
"$(__rvm_environment_identifier)" > "$dump_environment_file"
|
78
|
-
if [[ "$?" -gt 0 && -f "$dump_environment_file" ]] ; then
|
79
|
-
\rm -f "$dump_environment_file"
|
80
|
-
fi
|
81
|
-
fi
|
82
|
-
fi
|
83
|
-
|
84
|
-
return 0
|
85
|
-
}
|
86
|
-
|
87
|
-
# Return a list of directories under a given base path.
|
88
|
-
# Derived from rvm_ruby_string.
|
89
|
-
__rvm_ruby_string_paths_under()
|
90
|
-
{
|
91
|
-
local path part parts
|
92
|
-
|
93
|
-
path="${1%/}" # Strip off any trailing slash
|
94
|
-
|
95
|
-
parts=(${rvm_ruby_string//-/ }) # Strip white space.
|
96
|
-
|
97
|
-
echo "$path"
|
98
|
-
|
99
|
-
for part in "${parts[@]}" ; do
|
100
|
-
|
101
|
-
path="$path/$part"
|
102
|
-
|
103
|
-
echo "$path"
|
104
|
-
|
105
|
-
done
|
106
|
-
|
107
|
-
return 0
|
108
|
-
}
|
109
|
-
|
110
|
-
# Query the rvm key-value database for a specific key
|
111
|
-
# Allow overrides from user specifications in $rvm_path/config/user
|
112
|
-
__rvm_db()
|
113
|
-
{
|
114
|
-
local value key variable
|
115
|
-
|
116
|
-
key=${1:-""}
|
117
|
-
variable=${2:-""}
|
118
|
-
|
119
|
-
if [[ -f "$rvm_path/config/user" ]] ; then
|
120
|
-
value="$("$rvm_path/scripts/db" "$rvm_path/config/user" "$key")"
|
121
|
-
fi
|
122
|
-
|
123
|
-
if [[ -z "$value" ]] ; then
|
124
|
-
value="$("$rvm_path/scripts/db" "$rvm_path/config/db" "$key")"
|
125
|
-
fi
|
126
|
-
|
127
|
-
if [[ -n "$value" ]] ; then
|
128
|
-
if [[ -z "$variable" ]] ; then
|
129
|
-
echo $value
|
130
|
-
else
|
131
|
-
eval "$variable='$value'"
|
132
|
-
fi
|
133
|
-
fi
|
134
|
-
|
135
|
-
return 0
|
136
|
-
}
|
137
|
-
|
138
|
-
is_a_function() { type $1 | head -n 1 | \grep -q "function" ; }
|
139
|
-
|
140
|
-
__rvm_quote_args()
|
141
|
-
{
|
142
|
-
local quoted_string=""
|
143
|
-
|
144
|
-
for quoted_argument in "$@"; do
|
145
|
-
|
146
|
-
if printf "%s" "$quoted_argument" | \grep -vq "^[[:alnum:]]$"; then
|
147
|
-
|
148
|
-
quoted_string="$quoted_string '$(printf "%s" "$quoted_argument" \
|
149
|
-
| sed "s/'/\'\\\'\'/g")'"
|
150
|
-
|
151
|
-
else
|
152
|
-
quoted_string="$quoted_string $quoted_argument"
|
153
|
-
fi
|
154
|
-
done
|
155
|
-
|
156
|
-
echo "$quoted_string" | sed -e 's/^ *//g' -e 's/ *$//g'
|
157
|
-
|
158
|
-
return 0
|
159
|
-
}
|
160
|
-
|
161
|
-
__rvm_quote_args_with_shift()
|
162
|
-
{
|
163
|
-
local shift_value="$1"; shift
|
164
|
-
|
165
|
-
while [[ "$shift_value" -gt 0 && $# -gt 0 ]]; do
|
166
|
-
|
167
|
-
shift
|
168
|
-
|
169
|
-
((shift_value--))
|
170
|
-
|
171
|
-
done
|
172
|
-
|
173
|
-
__rvm_quote_args "$@"
|
174
|
-
|
175
|
-
return 0
|
176
|
-
}
|
177
|
-
|
178
|
-
__rvm_warn_on_rubyopt()
|
179
|
-
{
|
180
|
-
if [[ -n "${RUBYOPT:-""}" ]]; then
|
181
|
-
"$rvm_path/scripts"/log "warn" \
|
182
|
-
"Please note: You have the RUBYOPT environment variable set and this \
|
183
|
-
may interfere with normal rvm operations. We sugges unsetting it."
|
184
|
-
return 1
|
185
|
-
else
|
186
|
-
return 0
|
187
|
-
fi
|
188
|
-
}
|
189
|
-
|
190
|
-
__rvm_strings()
|
191
|
-
{
|
192
|
-
local strings ruby_strings
|
193
|
-
|
194
|
-
ruby_strings=($(echo ${rvm_ruby_args:-$rvm_ruby_string}))
|
195
|
-
|
196
|
-
for rvm_ruby_string in "${ruby_strings[@]}" ; do
|
197
|
-
strings="$strings $(__rvm_select ; echo $rvm_ruby_string)"
|
198
|
-
done
|
199
|
-
|
200
|
-
echo $strings
|
201
|
-
|
202
|
-
return 0
|
203
|
-
}
|
204
|
-
|
205
|
-
# Push an item onto a given array.
|
206
|
-
__rvm_push()
|
207
|
-
{
|
208
|
-
local array item
|
209
|
-
|
210
|
-
array=$1 ; shift ; item=$2
|
211
|
-
|
212
|
-
# TODO: allow loop over more arguments.
|
213
|
-
eval "index=\$((\${#${array}[*]} + $__shell_array_start))"
|
214
|
-
|
215
|
-
eval "${array}[${index}]=${item}"
|
216
|
-
|
217
|
-
return 0
|
218
|
-
}
|
219
|
-
|
220
|
-
# Clean all *duplicate* items out of the path. (keep first occurrence of each)
|
221
|
-
__rvm_clean_path()
|
222
|
-
{
|
223
|
-
PATH="$(printf "$PATH" | \tr -s ':' '\n' | awk '!($0 in a){a[$0];print}' \
|
224
|
-
| \tr -s '\n' ':' | sed 's#:$##')"
|
225
|
-
|
226
|
-
export PATH
|
227
|
-
|
228
|
-
builtin hash -r
|
229
|
-
}
|
230
|
-
|
231
|
-
# Clean all rvm items out of the current working path.
|
232
|
-
__rvm_remove_rvm_from_path()
|
233
|
-
{
|
234
|
-
PATH="$(printf "$PATH" \
|
235
|
-
| awk -v RS=: -v ORS=: "/${rvm_path//\//\/}/ {next} {print}" \
|
236
|
-
| sed -e 's#:$##')"
|
237
|
-
|
238
|
-
export PATH
|
239
|
-
|
240
|
-
builtin hash -r
|
241
|
-
}
|
242
|
-
|
243
|
-
# Run a specified command and log it.
|
244
|
-
__rvm_run()
|
245
|
-
{
|
246
|
-
local name log temp_log_path command message
|
247
|
-
|
248
|
-
name="${1:-""}"
|
249
|
-
command="${2:-""}"
|
250
|
-
message="${3:-""}"
|
251
|
-
|
252
|
-
if [[ -n "$message" ]] ; then
|
253
|
-
"$rvm_path/scripts/log" "info" "$message"
|
254
|
-
fi
|
255
|
-
|
256
|
-
if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
|
257
|
-
"$rvm_path/scripts/log" "debug" "Executing: $command"
|
258
|
-
fi
|
259
|
-
|
260
|
-
if [[ -n "${rvm_ruby_string:-""}" ]] ; then
|
261
|
-
temp_log_path="${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string"
|
262
|
-
else
|
263
|
-
temp_log_path="${rvm_log_path:-"$rvm_path/log"}"
|
264
|
-
fi
|
265
|
-
|
266
|
-
log="$temp_log_path/$name.log"
|
267
|
-
|
268
|
-
if [[ ! -d "${log%\/*}" ]] ; then
|
269
|
-
\mkdir -p "${log%\/*}"
|
270
|
-
fi
|
271
|
-
|
272
|
-
\touch "$log" # for zsh :(
|
273
|
-
|
274
|
-
printf "[$(date +'%Y-%m-%d %H:%M:%S')] $command\n" > "$log"
|
275
|
-
|
276
|
-
if [[ ${rvm_niceness:-0} -gt 0 ]] ; then
|
277
|
-
command="nice -n $rvm_niceness $command"
|
278
|
-
fi
|
279
|
-
|
280
|
-
eval "$command" >> "$log" 2>&1
|
281
|
-
|
282
|
-
result=$?
|
283
|
-
|
284
|
-
if [[ $result -gt 0 ]] ; then
|
285
|
-
"$rvm_path/scripts/log" "error" \
|
286
|
-
"Error running '$command', please read $log"
|
287
|
-
fi
|
288
|
-
|
289
|
-
return ${result:-0}
|
290
|
-
}
|
291
|
-
|
292
|
-
# Runs a command in a given env.
|
293
|
-
__rvm_run_with_env()
|
294
|
-
{
|
295
|
-
local name environment command message log path
|
296
|
-
|
297
|
-
name="${1:-""}"
|
298
|
-
environment="${2:-""}"
|
299
|
-
command="${3:-""}"
|
300
|
-
message="${4:-""}"
|
301
|
-
|
302
|
-
if [[ -z "$environment" ]] ; then
|
303
|
-
environment="$(__rvm_environment_identifier)"
|
304
|
-
fi
|
305
|
-
|
306
|
-
if [[ -n "$message" ]] ; then
|
307
|
-
"$rvm_path/scripts/log" "info" "$message"
|
308
|
-
fi
|
309
|
-
|
310
|
-
if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
|
311
|
-
"$rvm_path/scripts/log" "debug" \
|
312
|
-
"Executing: $command in environment $environment"
|
313
|
-
fi
|
314
|
-
|
315
|
-
path="${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string"
|
316
|
-
|
317
|
-
log="$path/$name.log"
|
318
|
-
|
319
|
-
if [[ ! -d "$path" ]] ; then
|
320
|
-
\mkdir -p "$path"
|
321
|
-
fi
|
322
|
-
|
323
|
-
\touch "$log" # for zsh :(
|
324
|
-
|
325
|
-
printf "[$(date +'%Y-%m-%d %H:%M:%S')] $command # under $environment\n" > "${log}"
|
326
|
-
|
327
|
-
if [[ ${rvm_niceness:-0} -gt 0 ]] ; then
|
328
|
-
command="nice -n $rvm_niceness $command"
|
329
|
-
fi
|
330
|
-
|
331
|
-
(
|
332
|
-
rvm_ruby_string="$environment"
|
333
|
-
|
334
|
-
__rvm_use
|
335
|
-
|
336
|
-
eval "$command" >> "${log}" 2>&1
|
337
|
-
)
|
338
|
-
|
339
|
-
result=$?
|
340
|
-
|
341
|
-
if [[ $result -gt 0 ]] ; then
|
342
|
-
"$rvm_path/scripts/log" "error" \
|
343
|
-
"Error running '$command' under $env_name,\nplease read $log"
|
344
|
-
fi
|
345
|
-
|
346
|
-
return ${result:-0}
|
347
|
-
}
|
348
|
-
|
349
|
-
__rvm_nuke_rvm_variables()
|
350
|
-
{
|
351
|
-
unset rvm_head_flag $(env | awk -F= '/^rvm_/{print $1" "}')
|
352
|
-
}
|
353
|
-
|
354
|
-
# Unset ruby-specific variables
|
355
|
-
__rvm_unset_ruby_variables()
|
356
|
-
{
|
357
|
-
# unset rvm_ruby_flag $(env | awk -F= '/^rvm_ruby_/{printf $1" "}')
|
358
|
-
unset rvm_ruby_string rvm_ruby_strings rvm_ruby_binary rvm_ruby_gem_home rvm_ruby_gem_path rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_log_path rvm_ruby_major_version rvm_ruby_minor_version rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_repo_branch rvm_ruby_revision rvm_ruby_selected_flag rvm_ruby_tag rvm_ruby_version rvm_ruby_load_path rvm_ruby_require rvm_head_flag rvm_ruby_package_file rvm_ruby_configure rvm_ruby_name
|
359
|
-
}
|
360
|
-
|
361
|
-
# TODO: Should be able to...
|
362
|
-
# Unset both rvm variables as well as ruby-specific variables
|
363
|
-
# Preserve gemset if 'rvm_sticky' is set
|
364
|
-
# (persist gemset unless clear is explicitely called).
|
365
|
-
__rvm_cleanse_variables()
|
366
|
-
{
|
367
|
-
__rvm_unset_ruby_variables
|
368
|
-
|
369
|
-
if [[ ${rvm_sticky_flag:-0} -eq 1 ]] ; then
|
370
|
-
export rvm_gemset_name
|
371
|
-
else
|
372
|
-
unset rvm_gemset_name
|
373
|
-
fi
|
374
|
-
|
375
|
-
unset rvm_ruby_string rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_force_flag rvm_all_flag rvm_reconfigure_flag rvm_make_flags rvm_bin_flag rvm_import_flag rvm_export_flag rvm_self_flag rvm_gem_flag rvm_rubygems_flag rvm_debug_flag rvm_delete_flag rvm_summary_flag rvm_test_flag _rvm_spec_flag rvm_json_flag rvm_yaml_flag rvm_shebang_flag rvm_env_flag rvm_tail_flag rvm_use_flag rvm_dir_flag rvm_list_flag rvm_empty_flag rvm_file_name rvm_benchmark_flag rvm_clear_flag rvm_name_flag rvm_verbose_flag rvm_user_flag rvm_system_flag rvm_configure_flags rvm_uninstall_flag rvm_install_flag rvm_llvm_flag rvm_ruby_bits rvm_sticky_flag rvm_rvmrc_flag rvm_gems_flag rvm_only_path_flag rvm_docs_flag rvm_ruby_aliases rvm_patch_names rvm_clang_flag rvm_install_arguments rvm_dump_environment_flag rvm_ruby_alias
|
376
|
-
}
|
377
|
-
|
378
|
-
# Returns the first 1.8.7-compatible (partly) ruby for use
|
379
|
-
# with things like rbx etc which require a ruby be installed.
|
380
|
-
__rvm_18_compat_ruby()
|
381
|
-
{
|
382
|
-
local rubies ruby_name
|
383
|
-
|
384
|
-
rubies=($( cd "$rvm_path/rubies" ; find . -maxdepth 1 -mindepth 1 -type d ))
|
385
|
-
|
386
|
-
for ruby_name in "${rubies[@]//.\/}"; do
|
387
|
-
|
388
|
-
if [[ ! -L "$rvm_path/rubies/$ruby_name" ]] ; then
|
389
|
-
|
390
|
-
case $ruby_name in
|
391
|
-
*1.8.*|rbx-*|ree-*) rubies="$rubies $ruby_name" ;;
|
392
|
-
esac
|
393
|
-
fi
|
394
|
-
done
|
395
|
-
|
396
|
-
echo $rubies | \tr ' ' '\n' | \sort | \tail -n1
|
397
|
-
|
398
|
-
return 0
|
399
|
-
}
|
400
|
-
|
401
|
-
__rvm_ensure_has_18_compat_ruby()
|
402
|
-
{
|
403
|
-
if [[ -z "$(__rvm_18_compat_ruby)" ]]; then
|
404
|
-
# TODO: install currently doesn't return the correct status.
|
405
|
-
local compat_result=0
|
406
|
-
|
407
|
-
if ! ( "$rvm_path/scripts/manage" install 1.8.7 ); then
|
408
|
-
|
409
|
-
"$rvm_path/scripts/log" "fail" \
|
410
|
-
"To proceed rvm requires a 1.8-compatible ruby is installed.\
|
411
|
-
\nWe attempted to install 1.8.7 automatically but it failed.\
|
412
|
-
\nPlease install it manually (or a compatible alternative) to proceed."
|
413
|
-
|
414
|
-
compat_result=1
|
415
|
-
|
416
|
-
fi
|
417
|
-
# unset original_ruby
|
418
|
-
# Question: Why *were* we unsetting original_ruby here
|
419
|
-
return $compat_result
|
420
|
-
fi
|
421
|
-
|
422
|
-
return 0
|
423
|
-
}
|
424
|
-
|
425
|
-
# Cleans up temp folders for a given prefix ($1),
|
426
|
-
# typically the current process id.
|
427
|
-
__rvm_cleanup_temp_for()
|
428
|
-
{
|
429
|
-
result=$? # Capture last command status
|
430
|
-
|
431
|
-
[[ -z "${1:-""}" ]] && return 1
|
432
|
-
|
433
|
-
if [[ -d "${rvm_tmp_path:-"$rvm_path/tmp"}/" ]]; then
|
434
|
-
|
435
|
-
\rm -rf "${rvm_tmp_path:-"$rvm_path/tmp"}/$1"* >/dev/null 2>&1
|
436
|
-
|
437
|
-
fi
|
438
|
-
|
439
|
-
return $result
|
440
|
-
}
|
441
|
-
|
442
|
-
__rvm_set_rvmrc()
|
443
|
-
{
|
444
|
-
local flags
|
445
|
-
|
446
|
-
if [[ "$HOME" != "$PWD" ]] ; then
|
447
|
-
|
448
|
-
if [[ ${rvm_verbose_flag:-0} -gt 0 ]] ; then
|
449
|
-
flags="use "
|
450
|
-
fi
|
451
|
-
|
452
|
-
if [[ -s .rvmrc ]] ; then
|
453
|
-
|
454
|
-
mv .rvmrc .rvmrc.$(date +%m.%d.%Y-%H:%M:%S)
|
455
|
-
|
456
|
-
"$rvm_path/scripts/log" "warning" \
|
457
|
-
".rvmrc is not empty, moving aside to preserve."
|
458
|
-
|
459
|
-
fi
|
460
|
-
|
461
|
-
local identifier=$(__rvm_environment_identifier)
|
462
|
-
|
463
|
-
printf "
|
464
|
-
if [[ -d \"\${rvm_path:-\$HOME/.rvm}/environments\" \\
|
465
|
-
&& -s \"\${rvm_path:-\$HOME/.rvm}/environments/$identifier\" ]] ; then
|
466
|
-
\\. \"\${rvm_path:-\$HOME/.rvm}/environments/$identifier\"
|
467
|
-
else
|
468
|
-
rvm --create $flags \"$identifier\"
|
469
|
-
fi
|
470
|
-
" >> .rvmrc
|
471
|
-
|
472
|
-
else
|
473
|
-
"$rvm_path/scripts/log" "error" \
|
474
|
-
".rvmrc cannot be set in your home directory.\
|
475
|
-
\nThe home .rvmrc is for global rvm settings only."
|
476
|
-
fi
|
477
|
-
}
|
478
|
-
|
479
|
-
__rvm_load_rvmrc()
|
480
|
-
{
|
481
|
-
[[ ${rvm_ignore_rvmrc:-0} -eq 1 ]] && return 0
|
482
|
-
|
483
|
-
for rvmrc in /etc/rvmrc $HOME/.rvmrc ; do
|
484
|
-
|
485
|
-
if [[ -f "$rvmrc" ]] ; then
|
486
|
-
|
487
|
-
if \grep -q '^\s*rvm .*$' $rvmrc ; then
|
488
|
-
|
489
|
-
"$rvm_path/scripts/log" "error" \
|
490
|
-
"$rvmrc is for rvm settings only.\
|
491
|
-
\nrvm CLI may NOT be called from within $rvmrc.\
|
492
|
-
\nSkipping the loading of $rvmrc"
|
493
|
-
|
494
|
-
return 1
|
495
|
-
|
496
|
-
else
|
497
|
-
|
498
|
-
source "$rvmrc"
|
499
|
-
|
500
|
-
fi
|
501
|
-
|
502
|
-
fi
|
503
|
-
|
504
|
-
done
|
505
|
-
|
506
|
-
return 0
|
507
|
-
}
|
508
|
-
|
509
|
-
# Wrap the specified ruby code file in a Benchmark.bmbm block and execute it.
|
510
|
-
__rvm_benchmark()
|
511
|
-
{
|
512
|
-
local old_rvm_ruby_string
|
513
|
-
|
514
|
-
code="require \"benchmark\" \n \
|
515
|
-
Benchmark.bmbm do |benchmark| \n \
|
516
|
-
benchmark.report(\"${rvm_ruby_file}\") do \n"
|
517
|
-
|
518
|
-
printf "\n$code" > "${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb"
|
519
|
-
|
520
|
-
unset code
|
521
|
-
|
522
|
-
cat $rvm_ruby_file >> "${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb"
|
523
|
-
|
524
|
-
printf "\n end \nend\n" >> "${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb"
|
525
|
-
|
526
|
-
rvm_ruby_args="${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb"
|
527
|
-
|
528
|
-
rvm_benchmark_flag=1
|
529
|
-
|
530
|
-
rvm_action="ruby"
|
531
|
-
|
532
|
-
if [[ ${rvm_debug_flag:0} -gt 0 ]] ; then
|
533
|
-
|
534
|
-
printf "\n${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb:\n\
|
535
|
-
$(cat ${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb)"
|
536
|
-
|
537
|
-
fi
|
538
|
-
|
539
|
-
# Override ruby string stuff, pass through.
|
540
|
-
|
541
|
-
old_rvm_ruby_string=$rvm_ruby_string
|
542
|
-
|
543
|
-
# TODO: We can likely do this in a subshell in order to
|
544
|
-
# preserve the original environment?
|
545
|
-
|
546
|
-
unset rvm_ruby_string
|
547
|
-
|
548
|
-
export rvm_ruby_strings
|
549
|
-
|
550
|
-
"$rvm_path/scripts/set" "$rvm_action" $rvm_ruby_args ; result=$?
|
551
|
-
|
552
|
-
# Restore the state pre-sets.
|
553
|
-
[[ -n "$old_rvm_ruby_string" ]] && rvm_ruby_string=$old_rvm_ruby_string
|
554
|
-
|
555
|
-
return ${result:-0}
|
556
|
-
}
|
557
|
-
|
558
|
-
# Loop over the currently installed rubies and refresh their binscripts.
|
559
|
-
__rvm_bin_scripts()
|
560
|
-
{
|
561
|
-
for rvm_ruby_binary in "$rvm_path/rubies"/*/bin/ruby ; do
|
562
|
-
|
563
|
-
if [[ -x "$rvm_ruby_binary" ]] ; then
|
564
|
-
|
565
|
-
rvm_ruby_string=$(dirname "$rvm_ruby_binary" \
|
566
|
-
| xargs dirname | xargs basename)
|
567
|
-
|
568
|
-
__rvm_select
|
569
|
-
|
570
|
-
__rvm_bin_script
|
571
|
-
|
572
|
-
fi
|
573
|
-
|
574
|
-
done
|
575
|
-
|
576
|
-
return 0
|
577
|
-
}
|
578
|
-
|
579
|
-
# Write the bin/ wrapper script for currently selected ruby.
|
580
|
-
# TODO: Adjust binscript to be able to handle all rubies,
|
581
|
-
# not just the standard interpreteres.
|
582
|
-
__rvm_bin_script()
|
583
|
-
{
|
584
|
-
"$rvm_path/scripts/wrapper" "$rvm_ruby_string"
|
585
|
-
|
586
|
-
return $?
|
587
|
-
}
|
588
|
-
|
589
|
-
# Add bin path if not present
|
590
|
-
__rvm_conditionally_add_bin_path()
|
591
|
-
{
|
592
|
-
if printf "${PATH//:/ }" | \grep -vqF "${rvm_bin_path:-"$rvm_path/bin"} " ; then
|
593
|
-
|
594
|
-
case "${rvm_ruby_string:-"system"}" in
|
595
|
-
system)
|
596
|
-
PATH="$PATH:${rvm_bin_path:-"$rvm_path/bin"}"
|
597
|
-
;;
|
598
|
-
*)
|
599
|
-
PATH="${rvm_bin_path:-"$rvm_path/bin"}:$PATH"
|
600
|
-
;;
|
601
|
-
esac
|
602
|
-
|
603
|
-
builtin hash -r
|
604
|
-
fi
|
605
|
-
|
606
|
-
return 0
|
607
|
-
}
|
608
|
-
|
609
|
-
# Reset any rvm gathered information about the system and its state.
|
610
|
-
# rvm will refresh the stored information the next time it is called after reset.
|
611
|
-
__rvm_reset()
|
612
|
-
{
|
613
|
-
local flag flags file files config configs variable
|
614
|
-
|
615
|
-
__rvm_remove_rvm_from_path ; __rvm_conditionally_add_bin_path
|
616
|
-
|
617
|
-
export PATH
|
618
|
-
|
619
|
-
builtin hash -r
|
620
|
-
|
621
|
-
flags=( default passenger editor )
|
622
|
-
|
623
|
-
for flag in "${flags[@]}"; do
|
624
|
-
|
625
|
-
\rm -f "${rvm_bin_path:-"$rvm_path/bin"}"/${flag}_*
|
626
|
-
|
627
|
-
done
|
628
|
-
|
629
|
-
for file in system default ; do
|
630
|
-
|
631
|
-
if [[ -f "$rvm_path/${file}" ]] ; then
|
632
|
-
\rm -f "$rvm_path/${file}"
|
633
|
-
fi
|
634
|
-
|
635
|
-
if [[ -f "$rvm_path/config/${file}" ]] ; then
|
636
|
-
\rm -f "$rvm_path/config/${file}"
|
637
|
-
fi
|
638
|
-
|
639
|
-
if [[ -f "$rvm_path/environments/${file}" ]] ; then
|
640
|
-
\rm -f "$rvm_path/environments/${file}"
|
641
|
-
fi
|
642
|
-
|
643
|
-
done
|
644
|
-
|
645
|
-
# Go back to a clean state.
|
646
|
-
__rvm_use_system
|
647
|
-
|
648
|
-
__rvm_unset_ruby_variables
|
649
|
-
|
650
|
-
configs=(system_ruby system_gem_path system_user_gem_path)
|
651
|
-
|
652
|
-
for system_config in "${configs[@]}" ; do
|
653
|
-
|
654
|
-
"$rvm_path/scripts/db" "$rvm_path/config/user" "$system_config" "delete"
|
655
|
-
|
656
|
-
done
|
657
|
-
|
658
|
-
files=(ruby gem rake irb $(cd "${rvm_bin_path:-"$rvm_path/bin"}" ; \
|
659
|
-
find . -mindepth 1 -maxdepth 1 -iname 'default*' -type f \
|
660
|
-
| sed -e 's#./##g'))
|
661
|
-
|
662
|
-
for file in "${files[@]}"; do
|
663
|
-
|
664
|
-
if [[ -f "${rvm_bin_path:-"$rvm_path/bin"}/$file" ]] ; then
|
665
|
-
|
666
|
-
\rm -f "${rvm_bin_path:-"$rvm_path/bin"}/$file"
|
667
|
-
|
668
|
-
fi
|
669
|
-
|
670
|
-
done
|
671
|
-
|
672
|
-
return 0
|
673
|
-
}
|
674
|
-
|
675
|
-
# Implode removes the entire rvm installation under $rvm_path.
|
676
|
-
__rvm_implode()
|
677
|
-
{
|
678
|
-
while : ; do
|
679
|
-
|
680
|
-
"$rvm_path/scripts/log" "warn" \
|
681
|
-
"Are you SURE you wish for rvm to implode?\
|
682
|
-
\nThis will recursively remove $rvm_path ?\
|
683
|
-
\n(type 'yes' or 'no')> "
|
684
|
-
|
685
|
-
read response
|
686
|
-
|
687
|
-
if [[ "yes" = "$response" ]] ; then
|
688
|
-
|
689
|
-
if [[ "/" = "$rvm_path" ]] ; then
|
690
|
-
|
691
|
-
"$rvm_path/scripts/log" "error" \
|
692
|
-
"remove '/' ?!... Ni!"
|
693
|
-
|
694
|
-
else
|
695
|
-
|
696
|
-
if [[ -d "$rvm_path" ]] ; then
|
697
|
-
|
698
|
-
"$rvm_path/scripts/log" "info" \
|
699
|
-
"Hai! Removing $rvm_path"
|
700
|
-
|
701
|
-
\rm -rf "$rvm_path/"
|
702
|
-
|
703
|
-
echo "$rvm_path has been removed."
|
704
|
-
|
705
|
-
else
|
706
|
-
|
707
|
-
"$rvm_path/scripts/log" "info" \
|
708
|
-
"It appears that $rvm_path is already non existant."
|
709
|
-
|
710
|
-
fi
|
711
|
-
fi
|
712
|
-
break
|
713
|
-
|
714
|
-
elif [[ "no" = "$response" ]] ; then
|
715
|
-
|
716
|
-
"$rvm_path/scripts/log" "info" \
|
717
|
-
"Cancelling implosion, no harm done :)"
|
718
|
-
break
|
719
|
-
|
720
|
-
fi
|
721
|
-
done
|
722
|
-
|
723
|
-
return 0
|
724
|
-
}
|
725
|
-
|
726
|
-
# Output the current ruby's rvm source path.
|
727
|
-
__rvm_source_dir()
|
728
|
-
{
|
729
|
-
if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select ; fi
|
730
|
-
|
731
|
-
if [[ -z "$rvm_ruby_src_path" ]] ; then
|
732
|
-
|
733
|
-
"$rvm_path/scripts/log" "fail" \
|
734
|
-
"No source directory exists for the default implementation."
|
735
|
-
|
736
|
-
else
|
737
|
-
|
738
|
-
echo "$rvm_ruby_src_path"
|
739
|
-
|
740
|
-
fi
|
741
|
-
|
742
|
-
return 0
|
743
|
-
}
|
744
|
-
|
745
|
-
# Initialize rvm, ensuring that the path and directories are as expected.
|
746
|
-
__rvm_initialize()
|
747
|
-
{
|
748
|
-
rvm_ruby_load_path="."
|
749
|
-
rvm_ruby_require=""
|
750
|
-
|
751
|
-
__rvm_clean_path ; __rvm_conditionally_add_bin_path ; export PATH
|
752
|
-
|
753
|
-
if [[ ! -d "${rvm_tmp_path:-"$rvm_path/tmp"}" ]] ; then
|
754
|
-
\mkdir -p "${rvm_tmp_path:-"$rvm_path/tmp"}"
|
755
|
-
fi
|
756
|
-
|
757
|
-
return 0
|
758
|
-
}
|
759
|
-
|
760
|
-
# Update rubygems or binscripts based on CLI selection.
|
761
|
-
__rvm_update()
|
762
|
-
{
|
763
|
-
(
|
764
|
-
builtin cd "$rvm_path"
|
765
|
-
|
766
|
-
# TODO:
|
767
|
-
if [[ ${rvm_head_flag:-0} -eq 1 || ${rvm_self_flag:-0} -eq 1 \
|
768
|
-
|| "update" = "${rvm_action:-""}" || ${rvm_update_flag:-0} -eq 1 ]] ; then
|
769
|
-
"$rvm_path/scripts/log" "warn" \
|
770
|
-
"'rvm update --head' is deprecated, use 'rvm get head' instead"
|
771
|
-
"$rvm_path/scripts/get" head
|
772
|
-
fi
|
773
|
-
|
774
|
-
if [[ ${rvm_bin_flag:-0} -eq 1 ]] ; then
|
775
|
-
__rvm_bin_scripts
|
776
|
-
fi
|
777
|
-
|
778
|
-
# Update to the latest rubygems.
|
779
|
-
if [[ ${rvm_rubygems_flag:-0} -eq 1 ]] ; then
|
780
|
-
"$rvm_path/scripts/rubygems" current
|
781
|
-
fi
|
782
|
-
)
|
783
|
-
unset rvm_update_flag rvm_action rvm_self_flag \
|
784
|
-
rvm_ruby_revision rvm_bin_flag rvm_rubygems_flag
|
785
|
-
|
786
|
-
return 0
|
787
|
-
}
|
788
|
-
|
789
|
-
__rvm_reboot()
|
790
|
-
{
|
791
|
-
"$rvm_path/scripts/log" "warn" \
|
792
|
-
"Do you wish to reboot rvm?\
|
793
|
-
\n('yes', or 'no')> "
|
794
|
-
|
795
|
-
local response="no"
|
796
|
-
|
797
|
-
read response
|
798
|
-
|
799
|
-
if [[ "yes" = "$response" ]] ; then
|
800
|
-
builtin cd $rvm_path
|
801
|
-
|
802
|
-
__rvm_reset
|
803
|
-
|
804
|
-
mv "$rvm_path/archives" "$HOME/.archives"
|
805
|
-
|
806
|
-
if [[ "/" = "$rvm_path" ]] ; then
|
807
|
-
"$rvm_path/scripts/log" "error" "remove '/' ?!... NO!"
|
808
|
-
else
|
809
|
-
if [[ -d "$rvm_path" ]] ; then \rm -rf "$rvm_path/" ; fi
|
810
|
-
fi
|
811
|
-
|
812
|
-
gem install rvm $rvm_gem_options
|
813
|
-
|
814
|
-
"$rvm_path/scripts/get" latest
|
815
|
-
|
816
|
-
source "$rvm_path/scripts/rvm"
|
817
|
-
else
|
818
|
-
"$rvm_path/scripts/log" "info" "Carry on then..."
|
819
|
-
fi
|
820
|
-
|
821
|
-
return 0
|
822
|
-
}
|
823
|
-
|
824
|
-
# Create the irbrc for the currently selected ruby installation.
|
825
|
-
__rvm_irbrc()
|
826
|
-
{
|
827
|
-
if [[ -d "$rvm_ruby_home" && ! -s "$rvm_ruby_irbrc" ]] ; then
|
828
|
-
\cp "$rvm_path/scripts/irbrc" "$rvm_ruby_irbrc"
|
829
|
-
fi
|
830
|
-
return $?
|
831
|
-
}
|
832
|
-
|
833
|
-
# Save or restore the rvm's state. This is a toggle action.
|
834
|
-
# Meant for use before and after an operation that might reset
|
835
|
-
# the currently selected ruby.
|
836
|
-
# TODO: Determine if we should a) yank this out or b) actually use it :)
|
837
|
-
__rvm_state()
|
838
|
-
{
|
839
|
-
if [[ -z "$rvm_state" ]] ; then
|
840
|
-
|
841
|
-
rvm_state="$(__rvm_environment_identifier)"
|
842
|
-
|
843
|
-
rvm_state="${rvm_state:-"system"}"
|
844
|
-
|
845
|
-
if [[ -n "$1" ]]; then
|
846
|
-
|
847
|
-
rvm_ruby_string="$1"
|
848
|
-
|
849
|
-
__rvm_select
|
850
|
-
|
851
|
-
__rvm_use
|
852
|
-
|
853
|
-
fi
|
854
|
-
|
855
|
-
else
|
856
|
-
|
857
|
-
rvm_ruby_string="$rvm_state"
|
858
|
-
|
859
|
-
__rvm_select
|
860
|
-
|
861
|
-
__rvm_use
|
862
|
-
|
863
|
-
unset rvm_state
|
864
|
-
|
865
|
-
fi
|
866
|
-
|
867
|
-
return 0
|
868
|
-
}
|
869
|
-
|
870
|
-
# Output an inspection of selected 'binary' scripts, based on CLI selection.
|
871
|
-
__rvm_inspect()
|
872
|
-
{
|
873
|
-
for binary in $rvm_ruby_args ; do
|
874
|
-
|
875
|
-
actual_file="$(unset -f gem ; command -v gem )"
|
876
|
-
|
877
|
-
"$rvm_path/scripts/log" "info" "$actual_file:"
|
878
|
-
|
879
|
-
if [[ ${rvm_shebang_flag:-0} -eq 1 ]] ; then
|
880
|
-
\head -n 1 < "$actual_file"
|
881
|
-
fi
|
882
|
-
|
883
|
-
if [[ ${rvm_env_flag:-0} -eq 1 ]] ; then
|
884
|
-
\awk '/ENV/' < "$actual_file"
|
885
|
-
fi
|
886
|
-
|
887
|
-
if [[ ${rvm_path_flag:-0} -eq 1 ]] ; then
|
888
|
-
\awk '/PATH/' < "$actual_file"
|
889
|
-
fi
|
890
|
-
|
891
|
-
if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then
|
892
|
-
\head -n 5 < "$actual_file"
|
893
|
-
fi
|
894
|
-
|
895
|
-
if [[ ${rvm_tail_flag:-0} -eq 1 ]] ; then
|
896
|
-
\tail -n 5 < "$actual_file"
|
897
|
-
fi
|
898
|
-
|
899
|
-
if [[ ${rvm_all_flag:-0} -eq 1 ]] ; then
|
900
|
-
\cat $actual_file
|
901
|
-
fi
|
902
|
-
|
903
|
-
done
|
904
|
-
|
905
|
-
return 0
|
906
|
-
}
|
907
|
-
|
908
|
-
# Attempt to override the Darwin build settings for rubies
|
909
|
-
# This should only be used in extreme edge cases that
|
910
|
-
# will not work via the default way.
|
911
|
-
__rvm_make_flags()
|
912
|
-
{
|
913
|
-
# This is only an issue with Darwin :/
|
914
|
-
if [[ "Darwin" = "$(uname)" ]] ; then
|
915
|
-
# \ls /usr/lib/gcc/x86_64-apple-darwin10
|
916
|
-
|
917
|
-
# Set the build & host type
|
918
|
-
if [[ "Power Macintosh" = "$(/usr/sbin/sysctl -n hw.machine)" ]] ; then
|
919
|
-
|
920
|
-
: # Do nothing ?
|
921
|
-
|
922
|
-
elif [[ "$(/usr/sbin/sysctl -n hw.cpu64bit_capable)" = 1 \
|
923
|
-
|| "$(/usr/sbin/sysctl -n hw.optional.x86_64)" = 1 ]] ; then
|
924
|
-
|
925
|
-
# 64 bit capable
|
926
|
-
|
927
|
-
if [[ "-arch x86_64" = "${rvm_archflags:-""}" ]] ; then
|
928
|
-
|
929
|
-
rvm_configure_flags="${rvm_configure_flags} \
|
930
|
-
--build=x86_64-apple-darwin$(uname -r) \
|
931
|
-
--host=x86_64-apple-darwin$(uname -r)"
|
932
|
-
|
933
|
-
elif [[ "-arch i386" = "${rvm_archflags:-""}" ]] ; then
|
934
|
-
|
935
|
-
rvm_configure_flags="${rvm_configure_flags} \
|
936
|
-
--build=i386-apple-darwin$(uname -r) \
|
937
|
-
--host=i386-apple-darwin$(uname -r)"
|
938
|
-
|
939
|
-
else
|
940
|
-
|
941
|
-
rvm_archflags="-arch x86_64"
|
942
|
-
|
943
|
-
rvm_configure_flags="${rvm_configure_flags} \
|
944
|
-
--build=x86_64-apple-darwin$(uname -r) \
|
945
|
-
--host=x86_64-apple-darwin$(uname -r)"
|
946
|
-
|
947
|
-
fi
|
948
|
-
|
949
|
-
fi
|
950
|
-
|
951
|
-
if [[ -n "${rvm_archflags:-""}" ]] ; then
|
952
|
-
|
953
|
-
ARCHFLAGS="$rvm_archflags" ; export ARCHFLAGS
|
954
|
-
|
955
|
-
# Use the latest sdk available.
|
956
|
-
if [[ -z "${rvm_sdk:-""}" ]] ; then
|
957
|
-
|
958
|
-
rvm_sdk="$(/usr/bin/basename -a /Developer/SDKs/* \
|
959
|
-
| awk '/^M/' | \sort | \tail -n 1)"
|
960
|
-
|
961
|
-
fi
|
962
|
-
|
963
|
-
CFLAGS="${CFLAGS:-"-isysroot /Developer/SDKs/$rvm_sdk $rvm_archflags"}"
|
964
|
-
|
965
|
-
export CFLAGS
|
966
|
-
|
967
|
-
LDFLAGS="${LDFLAGS:-"-Wl,-syslibroot /Developer/SDKs/$rvm_sdk $rvm_archflags"}"
|
968
|
-
|
969
|
-
export LDFLAGS
|
970
|
-
|
971
|
-
# CXXFLAGS="-mmacosx-version-min="$(sw_vers -productVersion \
|
972
|
-
# | awk -F'.' '{print $1"."$2}')" -isysroot /Developer/SDKs/$rvm_sdk "
|
973
|
-
# export CXXFLAGS
|
974
|
-
|
975
|
-
fi
|
976
|
-
fi
|
977
|
-
|
978
|
-
return 0
|
979
|
-
}
|
980
|
-
|
981
|
-
__rvm_mono_env()
|
982
|
-
{
|
983
|
-
DYLD_LIBRARY_PATH="${rvm_usr_path:-"$rvm_path/usr"}/lib:$DYLD_LIBRARY_PATH"
|
984
|
-
C_INCLUDE_PATH="${rvm_usr_path:-"$rvm_path/usr"}/include:$C_INCLUDE_PATH"
|
985
|
-
ACLOCAL_PATH="${rvm_usr_path:-"$rvm_path/usr"}/share/aclocal"
|
986
|
-
ACLOCAL_FLAGS="-I $ACLOCAL_PATH"
|
987
|
-
PKG_CONFIG_PATH="${rvm_usr_path:-"$rvm_path/usr"}/lib/pkgconfig:$PKG_CONFIG_PATH"
|
988
|
-
|
989
|
-
export DYLD_LIBRARY_PATH C_INCLUDE_PATH ACLOCAL_PATH ACLOCAL_FLAGS PKG_CONFIG_PATH
|
990
|
-
|
991
|
-
PATH="${rvm_usr_path:-"$rvm_path/usr"}/bin:$PATH"
|
992
|
-
|
993
|
-
builtin hash -r
|
994
|
-
|
995
|
-
return 0
|
996
|
-
}
|
997
|
-
|
998
|
-
__rvm_become()
|
999
|
-
{
|
1000
|
-
local string="$1"
|
1001
|
-
|
1002
|
-
[[ -n "$string" ]] && rvm_ruby_string="$string"
|
1003
|
-
|
1004
|
-
{ __rvm_ruby_string && __rvm_select && __rvm_use; } > /dev/null 2>&1
|
1005
|
-
|
1006
|
-
return 0
|
1007
|
-
}
|
1008
|
-
|
1009
|
-
__rvm_ensure_has_environment_files()
|
1010
|
-
{
|
1011
|
-
local environment_id file_name directory identifier variable value variables
|
1012
|
-
|
1013
|
-
environment_id="$(__rvm_environment_identifier)"
|
1014
|
-
|
1015
|
-
file_name="${rvm_path}/environments/$environment_id"
|
1016
|
-
|
1017
|
-
if [[ ! -s "$file_name" ]] ; then
|
1018
|
-
|
1019
|
-
\mkdir -p "$rvm_path/environments"
|
1020
|
-
|
1021
|
-
printf "export PATH=\"${rvm_ruby_gem_home}/bin:${rvm_ruby_global_gems_path}/bin:${rvm_ruby_home}/bin:${rvm_bin_path:-"$rvm_path/bin"}:\$PATH\"\n" \
|
1022
|
-
> "$file_name"
|
1023
|
-
|
1024
|
-
for variable in rvm_path RUBY_VERSION GEM_HOME GEM_PATH \
|
1025
|
-
MY_RUBY_HOME IRBRC rvm_ruby_string rvm_gemset_name MAGLEV_HOME ; do
|
1026
|
-
|
1027
|
-
eval "export $variable"
|
1028
|
-
eval "value=\${${variable}:-""}"
|
1029
|
-
|
1030
|
-
if [[ -n "$value" ]] ; then
|
1031
|
-
|
1032
|
-
printf "${variable}='$value'\nexport ${variable}\n" \
|
1033
|
-
>> "$file_name"
|
1034
|
-
|
1035
|
-
else
|
1036
|
-
|
1037
|
-
printf "unset ${variable}\n" \
|
1038
|
-
>> "$file_name"
|
1039
|
-
|
1040
|
-
fi
|
1041
|
-
|
1042
|
-
done
|
1043
|
-
fi
|
1044
|
-
|
1045
|
-
# Next, ensure we have default wrapper files. Also, prevent it from recursing.
|
1046
|
-
if [[ ${rvm_create_default_wrappers:-0} -eq 1 \
|
1047
|
-
|| ! -f "$rvm_path/wrappers/$environment_id/ruby" ]] ; then
|
1048
|
-
|
1049
|
-
# We need to generate wrappers for both the default gemset and the global gemset.
|
1050
|
-
for identifier in "$environment_id" "${environment_id//@*/}@global" ; do
|
1051
|
-
|
1052
|
-
rvm_create_default_wrappers=1
|
1053
|
-
|
1054
|
-
directory="$rvm_path/wrappers/$identifier"
|
1055
|
-
|
1056
|
-
if [[ ! -L "$directory" && ! -d "$directory" ]]; then
|
1057
|
-
\mkdir -p "$directory"
|
1058
|
-
|
1059
|
-
"$rvm_path/scripts/wrapper" "$identifier" &> /dev/null
|
1060
|
-
fi
|
1061
|
-
|
1062
|
-
done
|
1063
|
-
|
1064
|
-
rvm_create_default_wrappers=0
|
1065
|
-
fi
|
1066
|
-
|
1067
|
-
return 0
|
1068
|
-
}
|
1069
|
-
|
1070
|
-
# Strip whitespace and normalize it all.
|
1071
|
-
__rvm_strip()
|
1072
|
-
{
|
1073
|
-
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/[[:space:]]\{1,\}/ /g'
|
1074
|
-
return $?
|
1075
|
-
}
|
1076
|
-
|
1077
|
-
__rvm_using_gemset_globalcache()
|
1078
|
-
{
|
1079
|
-
"$rvm_path/scripts/db" "$rvm_path/config/user" \
|
1080
|
-
"use_gemset_globalcache" | \grep -q '^true$'
|
1081
|
-
return $?
|
1082
|
-
}
|
1083
|
-
|
1084
|
-
__rvm_current_gemcache_dir()
|
1085
|
-
{
|
1086
|
-
if __rvm_using_gemset_globalcache; then
|
1087
|
-
echo "$rvm_gems_cache_path"
|
1088
|
-
else
|
1089
|
-
echo "${rvm_ruby_gem_home:-"$GEM_HOME"}/cache"
|
1090
|
-
fi
|
1091
|
-
return 0
|
1092
|
-
}
|
1093
|
-
|
1094
|
-
__rvm_Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything()
|
1095
|
-
{
|
1096
|
-
for index in {1..750} ; do sleep 0.25 ; echo -n '.' ; done ; printf "%d" 0x2A
|
1097
|
-
echo
|
1098
|
-
return 0
|
1099
|
-
}
|
1100
|
-
|
1101
|
-
__rvm_ultimate_question()
|
1102
|
-
{
|
1103
|
-
printf "
|
1104
|
-
I do not know the Ultimate Question,
|
1105
|
-
however I can help you build a more
|
1106
|
-
powerful Ruby which can compute the
|
1107
|
-
Ultimate Question:
|
1108
|
-
|
1109
|
-
$ rvm install rbx
|
1110
|
-
|
1111
|
-
"
|
1112
|
-
return 0
|
1113
|
-
}
|
1114
|
-
|
1115
|
-
__rvm_load_env_file()
|
1116
|
-
{
|
1117
|
-
local string="$1"
|
1118
|
-
if [[ -f "$rvm_path/environments/$string" ]]; then
|
1119
|
-
# Restore the path to it's state minus rvm
|
1120
|
-
__rvm_remove_rvm_from_path
|
1121
|
-
|
1122
|
-
# source the environment file
|
1123
|
-
\. "$rvm_path/environments/$string"
|
1124
|
-
|
1125
|
-
# clear the PATH cache
|
1126
|
-
builtin hash -r
|
1127
|
-
elif [[ -n "$string" ]] ; then
|
1128
|
-
rvm "$string"
|
1129
|
-
else
|
1130
|
-
: # TODO: This should have some error handling in the context.
|
1131
|
-
fi
|
1132
|
-
return 0
|
1133
|
-
}
|
1134
|
-
|
1135
|
-
__rvm_md5_for()
|
1136
|
-
{
|
1137
|
-
if command -v md5 > /dev/null; then
|
1138
|
-
echo "$1" | md5
|
1139
|
-
elif command -v md5sum > /dev/null ; then
|
1140
|
-
echo "$1" | md5sum | awk '{print $1}'
|
1141
|
-
else
|
1142
|
-
"$rvm_path/scripts/log" "error" \
|
1143
|
-
"Neither md5 nor md5sum were found in the PATH"
|
1144
|
-
return 1
|
1145
|
-
fi
|
1146
|
-
|
1147
|
-
return 0
|
1148
|
-
}
|
1149
|
-
|
1150
|
-
__rvm_rvmrc_key()
|
1151
|
-
{
|
1152
|
-
__rvm_md5_for "$1"
|
1153
|
-
return $?
|
1154
|
-
}
|
1155
|
-
|
1156
|
-
__rvm_reset_rvmrc_trust()
|
1157
|
-
{
|
1158
|
-
touch "$rvm_path/config/rvmrcs"
|
1159
|
-
"$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" \
|
1160
|
-
"$(__rvm_rvmrc_key "$1")" "delete" >/dev/null 2>&1
|
1161
|
-
return $?
|
1162
|
-
}
|
1163
|
-
|
1164
|
-
__rvm_trust_rvmrc()
|
1165
|
-
{
|
1166
|
-
touch "$rvm_path/config/rvmrcs"
|
1167
|
-
__rvm_reset_rvmrc_trust "$1"
|
1168
|
-
"$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" \
|
1169
|
-
"$(__rvm_rvmrc_key "$1")" "1" >/dev/null 2>&1
|
1170
|
-
return $?
|
1171
|
-
}
|
1172
|
-
|
1173
|
-
__rvm_untrust_rvmrc()
|
1174
|
-
{
|
1175
|
-
touch "$rvm_path/config/rvmrcs"
|
1176
|
-
__rvm_reset_rvmrc_trust "$1"
|
1177
|
-
"$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" \
|
1178
|
-
"$(__rvm_rvmrc_key "$1")" "0" >/dev/null 2>&1
|
1179
|
-
return $?
|
1180
|
-
}
|
1181
|
-
|
1182
|
-
__rvm_rvmrc_stored_trust()
|
1183
|
-
{
|
1184
|
-
touch "$rvm_path/config/rvmrcs"
|
1185
|
-
"$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" \
|
1186
|
-
"$(__rvm_rvmrc_key "$1")"
|
1187
|
-
return $?
|
1188
|
-
}
|
1189
|
-
|
1190
|
-
__rvm_rvmrc_tools()
|
1191
|
-
{
|
1192
|
-
local rvmrc_action="$1"
|
1193
|
-
[[ $# -gt 0 ]] && shift
|
1194
|
-
local rvmrc_path="$(builtin cd "${1:-$PWD}" >/dev/null 2>&1; pwd)/.rvmrc"
|
1195
|
-
case "$rvmrc_action" in
|
1196
|
-
reset)
|
1197
|
-
__rvm_reset_rvmrc_trust "$rvmrc_path"
|
1198
|
-
echo "Reset trust for $rvmrc_path"
|
1199
|
-
;;
|
1200
|
-
trust)
|
1201
|
-
__rvm_trust_rvmrc "$rvmrc_path"
|
1202
|
-
echo "Marked $rvmrc_path as trusted"
|
1203
|
-
;;
|
1204
|
-
untrust)
|
1205
|
-
__rvm_untrust_rvmrc "$rvmrc_path"
|
1206
|
-
echo "Marked $rvmrc_path as untrusted"
|
1207
|
-
;;
|
1208
|
-
trusted)
|
1209
|
-
local trusted_value="$(__rvm_rvmrc_stored_trust "$rvmrc_path")"
|
1210
|
-
if [[ "$trusted_value" = "1" ]]; then
|
1211
|
-
echo "The rvmrc at '$rvmrc_path' is currently trusted."
|
1212
|
-
elif [[ "$trusted_value" = "0" ]]; then
|
1213
|
-
echo "The rvmrc at '$rvmrc_path' is currently untrusted."
|
1214
|
-
else
|
1215
|
-
echo "The trustiworthiness of '$rvmrc_path' is currently unknown."
|
1216
|
-
fi
|
1217
|
-
;;
|
1218
|
-
load)
|
1219
|
-
rvm_rvmrc_cwd="" rvm_trust_rvmrcs_flag=1 \
|
1220
|
-
__rvm_project_rvmrc "$(dirname "$rvmrc_path")"
|
1221
|
-
;;
|
1222
|
-
*)
|
1223
|
-
echo "Usage: rvm rvmrc {trust,untrust,trusted,load,reset}"
|
1224
|
-
return 1
|
1225
|
-
;;
|
1226
|
-
esac
|
1227
|
-
return $?
|
1228
|
-
}
|
1229
|
-
|
1230
|
-
__rvm_check_rvmrc_trustworthiness()
|
1231
|
-
{
|
1232
|
-
# Trust when they have the flag... of doom!
|
1233
|
-
[[ -z "$1" || "$rvm_trust_rvmrcs_flag" = "1" ]] && return 0
|
1234
|
-
value="$(__rvm_rvmrc_stored_trust "$1")"
|
1235
|
-
if [[ -z "$value" ]] ; then
|
1236
|
-
__rvm_ask_to_trust "$1"
|
1237
|
-
else
|
1238
|
-
[[ "$value" = "1" ]]
|
1239
|
-
fi
|
1240
|
-
return $?
|
1241
|
-
}
|
1242
|
-
|
1243
|
-
__rvm_ask_to_trust()
|
1244
|
-
{
|
1245
|
-
|
1246
|
-
local trusted value
|
1247
|
-
|
1248
|
-
[[ -n "$rvm_promptless" ]] && return 2
|
1249
|
-
|
1250
|
-
printf "
|
1251
|
-
============================================================
|
1252
|
-
RVM has encountered a not yet trusted .rvmrc file in the
|
1253
|
-
current working directory which contains the following code:
|
1254
|
-
============================================================
|
1255
|
-
|
1256
|
-
$(cat $1)
|
1257
|
-
|
1258
|
-
============================================================
|
1259
|
-
Trusting an .rvmrc file means that whenever you cd into the
|
1260
|
-
directory RVM will excecute this .rvmrc script in your shell
|
1261
|
-
|
1262
|
-
Do you wish to trust this .rvmrc from now on?
|
1263
|
-
============================================================
|
1264
|
-
(y for yes, n for no)"
|
1265
|
-
|
1266
|
-
# TODO: Eliminate infinite loop possibility.
|
1267
|
-
while [[ -z "$trusted" ]] ; do
|
1268
|
-
|
1269
|
-
printf " > "
|
1270
|
-
|
1271
|
-
read -r response
|
1272
|
-
|
1273
|
-
value="$(echo "$response" | tr '[[:upper:]]' '[[:lower:]]' | __rvm_strip)"
|
1274
|
-
|
1275
|
-
if [[ "$response" = "y"* ]]; then
|
1276
|
-
trusted=1
|
1277
|
-
|
1278
|
-
elif [[ "$response" = "n"* ]]; then
|
1279
|
-
trusted=0
|
1280
|
-
fi
|
1281
|
-
done
|
1282
|
-
|
1283
|
-
if [[ ${trusted:-0} -gt 0 ]] ; then
|
1284
|
-
|
1285
|
-
__rvm_trust_rvmrc "$1"
|
1286
|
-
|
1287
|
-
return 0
|
1288
|
-
|
1289
|
-
else
|
1290
|
-
__rvm_untrust_rvmrc "$1"
|
1291
|
-
return 1
|
1292
|
-
fi
|
1293
|
-
}
|
1294
|
-
|
1295
|
-
# Checks the rvmrc for the given directory. Note that if
|
1296
|
-
# argument is passed, it will be used instead of pwd.
|
1297
|
-
__rvm_project_rvmrc()
|
1298
|
-
{
|
1299
|
-
local cwd
|
1300
|
-
|
1301
|
-
# Get the first argument or the pwd.
|
1302
|
-
cwd="${1:-"$PWD"}"
|
1303
|
-
|
1304
|
-
while : ; do
|
1305
|
-
|
1306
|
-
if [[ -z "$cwd" || "$HOME" = "$cwd" || "/" = "$cwd" ]] ; then
|
1307
|
-
|
1308
|
-
if [[ -n "${rvm_rvmrc_cwd:-""}" ]] ; then
|
1309
|
-
|
1310
|
-
if [[ ${rvm_project_rvmrc_default:-0} -eq 1 ]]; then
|
1311
|
-
|
1312
|
-
__rvm_load_env_file "default"
|
1313
|
-
|
1314
|
-
elif [[ -n "${rvm_previous_environment:-""}" ]] ; then
|
1315
|
-
|
1316
|
-
__rvm_load_env_file "$rvm_previous_environment"
|
1317
|
-
|
1318
|
-
fi
|
1319
|
-
|
1320
|
-
unset rvm_rvmrc_cwd rvm_previous_environment
|
1321
|
-
|
1322
|
-
fi
|
1323
|
-
break
|
1324
|
-
else
|
1325
|
-
|
1326
|
-
if [[ -f "$cwd/.rvmrc" ]] ; then
|
1327
|
-
|
1328
|
-
if [[ "${rvm_rvmrc_cwd:-""}" != "$cwd" ]] ; then
|
1329
|
-
|
1330
|
-
__rvm_check_rvmrc_trustworthiness "$cwd/.rvmrc"
|
1331
|
-
|
1332
|
-
local rvm_trustworthiness_result="$?"
|
1333
|
-
|
1334
|
-
if [[ "$rvm_trustworthiness_result" = 0 ]]; then
|
1335
|
-
|
1336
|
-
rvm_previous_environment="$(__rvm_environment_identifier)"
|
1337
|
-
|
1338
|
-
rvm_rvmrc_cwd="$cwd"
|
1339
|
-
|
1340
|
-
source "$cwd/.rvmrc"
|
1341
|
-
|
1342
|
-
return 0
|
1343
|
-
else
|
1344
|
-
return "$rvm_trustworthiness_result"
|
1345
|
-
fi
|
1346
|
-
fi
|
1347
|
-
break
|
1348
|
-
|
1349
|
-
else
|
1350
|
-
cwd="$(dirname "$cwd")"
|
1351
|
-
fi
|
1352
|
-
fi
|
1353
|
-
done
|
1354
|
-
|
1355
|
-
return $?
|
1356
|
-
}
|
1357
|
-
|
1358
|
-
__rvm_record_install()
|
1359
|
-
{
|
1360
|
-
|
1361
|
-
local recorded_ruby_name rvm_install_record_file rvm_install_command
|
1362
|
-
|
1363
|
-
[[ -z "$1" ]] && return
|
1364
|
-
|
1365
|
-
recorded_ruby_name="$("$rvm_path/scripts/tools" strings "$1")"
|
1366
|
-
|
1367
|
-
rvm_install_record_file="$rvm_path/config/installs"
|
1368
|
-
|
1369
|
-
rvm_install_command=$(printf "$recorded_ruby_name $rvm_install_arguments\n")
|
1370
|
-
|
1371
|
-
\touch "$rvm_install_record_file"
|
1372
|
-
|
1373
|
-
\rm -f "$rvm_install_record_file.tmp"
|
1374
|
-
|
1375
|
-
\grep -v "^$recorded_ruby_name " < "$rvm_install_record_file" \
|
1376
|
-
> "$rvm_install_record_file.tmp"
|
1377
|
-
|
1378
|
-
echo "$rvm_install_command" >> "$rvm_install_record_file.tmp"
|
1379
|
-
|
1380
|
-
\rm -f "$rvm_install_record_file"
|
1381
|
-
|
1382
|
-
\mv "$rvm_install_record_file.tmp" "$rvm_install_record_file"
|
1383
|
-
|
1384
|
-
return 0
|
1385
|
-
}
|
1386
|
-
|
1387
|
-
__rvm_remove_install_record()
|
1388
|
-
{
|
1389
|
-
local recorded_ruby_name rvm_install_record_file
|
1390
|
-
|
1391
|
-
recorded_ruby_name="$("$rvm_path/scripts/tools" strings "$1")"
|
1392
|
-
|
1393
|
-
rvm_install_record_file="$rvm_path/config/installs"
|
1394
|
-
|
1395
|
-
if [[ -s "$rvm_install_record_file" ]]; then
|
1396
|
-
|
1397
|
-
\mv "$rvm_install_record_file" "$rvm_install_record_file.tmp"
|
1398
|
-
|
1399
|
-
\grep -v "^$recorded_ruby_name " < "$rvm_install_record_file.tmp" \
|
1400
|
-
> "$rvm_install_record_file"
|
1401
|
-
|
1402
|
-
\rm -f "$rvm_install_record_file.tmp"
|
1403
|
-
fi
|
1404
|
-
|
1405
|
-
return 0
|
1406
|
-
}
|
1407
|
-
|
1408
|
-
__rvm_recorded_install_command()
|
1409
|
-
{
|
1410
|
-
local recorded_ruby_name recorded_ruby_match
|
1411
|
-
|
1412
|
-
recorded_ruby_name="$("$rvm_path/scripts/tools" strings "$1" \
|
1413
|
-
| awk -F"${rvm_gemset_separator:-"@"}" '{print $1}')"
|
1414
|
-
|
1415
|
-
[[ -z "$recorded_ruby_name" ]] && return 1
|
1416
|
-
|
1417
|
-
recorded_ruby_match="^$recorded_ruby_name "
|
1418
|
-
|
1419
|
-
if [[ -s "$rvm_path/config/installs" ]] \
|
1420
|
-
&& \grep -q "$recorded_ruby_match" "$rvm_path/config/installs" ; then
|
1421
|
-
|
1422
|
-
\grep "$recorded_ruby_match" < "$rvm_path/config/installs" | head -n1
|
1423
|
-
|
1424
|
-
else
|
1425
|
-
return 1
|
1426
|
-
fi
|
1427
|
-
return $?
|
1428
|
-
}
|
1429
|
-
|
1430
|
-
__rvm_environment_identifier()
|
1431
|
-
{
|
1432
|
-
local path string
|
1433
|
-
|
1434
|
-
path="${GEM_HOME:-""}"
|
1435
|
-
|
1436
|
-
string="${path//*gems\//}"
|
1437
|
-
string="${string//\/*/}"
|
1438
|
-
|
1439
|
-
printf "${string:-system}"
|
1440
|
-
|
1441
|
-
return $?
|
1442
|
-
}
|
1443
|
-
|
1444
|
-
__rvm_expand_ruby_string()
|
1445
|
-
{
|
1446
|
-
local string current_ruby
|
1447
|
-
|
1448
|
-
string="$1"
|
1449
|
-
|
1450
|
-
if [[ -z "$string" ]] ; then
|
1451
|
-
|
1452
|
-
"$rvm_path/scripts/list" strings | tr ' ' "\n"
|
1453
|
-
|
1454
|
-
return $?
|
1455
|
-
|
1456
|
-
fi
|
1457
|
-
|
1458
|
-
case "$string" in
|
1459
|
-
|
1460
|
-
all)
|
1461
|
-
"$rvm_path/scripts/list" strings | tr ' ' "\n"
|
1462
|
-
;;
|
1463
|
-
|
1464
|
-
all-gemsets)
|
1465
|
-
"$rvm_path/scripts/list" gemsets strings
|
1466
|
-
;;
|
1467
|
-
|
1468
|
-
default-with-rvmrc|rvmrc)
|
1469
|
-
"$rvm_path/scripts/tools" path-identifier "$PWD"
|
1470
|
-
;;
|
1471
|
-
|
1472
|
-
all-rubies|rubies)
|
1473
|
-
"$rvm_path/scripts/list" rubies strings
|
1474
|
-
;;
|
1475
|
-
|
1476
|
-
current-ruby|gemsets)
|
1477
|
-
current_ruby="$(__rvm_environment_identifier \
|
1478
|
-
| awk -F"${rvm_gemset_separator:-"@"}" '{print $string}')"
|
1479
|
-
|
1480
|
-
rvm_silence_logging=1 "$rvm_path/scripts/gemsets" list \
|
1481
|
-
| sed "s/^/$current_ruby${rvm_gemset_separator:-"@"}/"
|
1482
|
-
;;
|
1483
|
-
|
1484
|
-
current)
|
1485
|
-
__rvm_environment_identifier
|
1486
|
-
;;
|
1487
|
-
|
1488
|
-
aliases)
|
1489
|
-
awk -F= '{print $string}' < "$rvm_path/config/alias"
|
1490
|
-
;;
|
1491
|
-
|
1492
|
-
*)
|
1493
|
-
echo "$string" | tr "," "\n" | __rvm_strip
|
1494
|
-
;;
|
1495
|
-
|
1496
|
-
esac
|
1497
|
-
|
1498
|
-
return $?
|
1499
|
-
}
|