rvm 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/binscripts/rvm +3 -2
- data/binscripts/rvm-update-head +2 -1
- data/binscripts/rvm-update-latest +2 -1
- data/binscripts/rvmsudo +3 -3
- data/contrib/install-system-wide +2 -1
- data/install +3 -2
- data/lib/VERSION.yml +1 -1
- data/rvm.gemspec +2 -3
- data/scripts/alias +14 -6
- data/scripts/array +1 -1
- data/scripts/cd +3 -2
- data/scripts/cleanup +1 -1
- data/scripts/cli +154 -98
- data/scripts/docs +5 -1
- data/scripts/env +4 -1
- data/scripts/environment-convertor +4 -2
- data/scripts/fetch +2 -0
- data/scripts/gemsets +133 -71
- data/scripts/hash +3 -3
- data/scripts/help +4 -3
- data/scripts/hook +7 -3
- data/scripts/info +18 -12
- data/scripts/install +3 -2
- data/scripts/list +48 -20
- data/scripts/log +15 -14
- data/scripts/maglev +1 -1
- data/scripts/manage +49 -33
- data/scripts/match +2 -2
- data/scripts/md5 +5 -3
- data/scripts/migrate +7 -3
- data/scripts/notes +5 -4
- data/scripts/package +7 -4
- data/scripts/patches +6 -5
- data/scripts/patchsets +8 -3
- data/scripts/repair +7 -4
- data/scripts/rubygems +5 -4
- data/scripts/rvm +11 -13
- data/scripts/rvm-install +3 -2
- data/scripts/selector +181 -106
- data/scripts/set +8 -7
- data/scripts/snapshot +6 -4
- data/scripts/tools +6 -4
- data/scripts/update +3 -2
- data/scripts/upgrade +13 -12
- data/scripts/utility +282 -117
- metadata +4 -5
- data/scripts/man +0 -0
data/scripts/set
CHANGED
@@ -100,7 +100,8 @@ __rvm_summary() {
|
|
100
100
|
summary="$summary \033[0;31m${#errors[*]} errors: $(echo "${errors[*]}" | sed 's# #, #g')\033[0m\n"
|
101
101
|
fi
|
102
102
|
total=${#rubies[*]}
|
103
|
-
if [[
|
103
|
+
if [[ -n "${ZSH_VERSION:-""}" ]] ; then array_start=1 ; else array_start=0 ; fi
|
104
|
+
|
104
105
|
printf "$summary" | tee -a log/summary.log
|
105
106
|
return ${#errors[*]}
|
106
107
|
}
|
@@ -114,7 +115,7 @@ __rvm_yaml() {
|
|
114
115
|
for var in ${errors[*]} ; do yaml="$yaml\n - $var" ; done
|
115
116
|
yaml="$yaml\nrubies:"
|
116
117
|
total=${#rubies[*]}
|
117
|
-
if [[
|
118
|
+
if [[ -n "${ZSH_VERSION:-""}" ]] ; then array_start=1 ; else array_start=0 ; fi
|
118
119
|
for (( index = $array_start ; index < $total + $array_start ; index++ )) ; do
|
119
120
|
if [[ ! -z "$rvm_debug_flag" ]] ; then
|
120
121
|
"$rvm_scripts_path/log" "debug" "${rubies[$index]}: ${statuses[$index]}"
|
@@ -136,7 +137,8 @@ __rvm_json() {
|
|
136
137
|
json="$json\n \"rubies\": {"
|
137
138
|
|
138
139
|
total=${#rubies[*]}
|
139
|
-
if [[
|
140
|
+
if [[ -n "${ZSH_VERSION:-""}" ]] ; then array_start=1 ; else array_start=0 ; fi
|
141
|
+
|
140
142
|
for (( index = $array_start ; index < $total + $array_start ; index++ )) ; do
|
141
143
|
if [[ ! -z "$rvm_debug_flag" ]] ; then
|
142
144
|
"$rvm_scripts_path/log" "debug" "${rubies[$index]}: ${statuses[$index]}"
|
@@ -157,10 +159,9 @@ __rvm_json() {
|
|
157
159
|
|
158
160
|
rubies=() ; successes=() ; errors=() ; statuses=()
|
159
161
|
|
160
|
-
|
161
|
-
action="$
|
162
|
-
[
|
163
|
-
args="$*"
|
162
|
+
args=($*)
|
163
|
+
action="${args[0]}"
|
164
|
+
args="$(echo ${args[@]:1}) " # Strip trailing / leading / extra spacing.
|
164
165
|
|
165
166
|
if [[ "$action" == "ruby" ]] && echo "$args" | \grep -q "^'--[^[:space:]]*'$" ; then
|
166
167
|
"$rvm_scripts_path/log" "warn" "You called rvm ruby with the arguments $args which look like use options."
|
data/scripts/snapshot
CHANGED
@@ -178,12 +178,14 @@ snapshot_usage() {
|
|
178
178
|
return 1
|
179
179
|
}
|
180
180
|
|
181
|
-
|
182
|
-
|
181
|
+
|
182
|
+
args=($*)
|
183
|
+
action="${args[0]}"
|
184
|
+
args="$(echo ${args[@]:1}) " # Strip trailing / leading / extra spacing.
|
183
185
|
|
184
186
|
case "$action" in
|
185
|
-
save) snapshot_save "
|
186
|
-
load) snapshot_load "
|
187
|
+
save) snapshot_save "$args" ;;
|
188
|
+
load) snapshot_load "$args" ;;
|
187
189
|
*) snapshot_usage ;;
|
188
190
|
esac
|
189
191
|
|
data/scripts/tools
CHANGED
@@ -38,14 +38,16 @@ tools_strings() {
|
|
38
38
|
done
|
39
39
|
}
|
40
40
|
|
41
|
-
|
41
|
+
args=($*)
|
42
|
+
action="${args[0]}"
|
43
|
+
args="$(echo ${args[@]:1}) " # Strip trailing / leading / extra spacing.
|
42
44
|
|
43
|
-
|
45
|
+
[[ -z "$action" ]] && usage
|
44
46
|
|
45
47
|
case "$action" in
|
46
48
|
identifier) tools_identifier ;;
|
47
|
-
path-identifier) tools_path_identifier "
|
48
|
-
strings) tools_strings "
|
49
|
+
path-identifier) tools_path_identifier "$args" ;;
|
50
|
+
strings) tools_strings "$args" ;;
|
49
51
|
*) usage ;;
|
50
52
|
esac
|
51
53
|
|
data/scripts/update
CHANGED
@@ -201,7 +201,7 @@ fi
|
|
201
201
|
spinner
|
202
202
|
if [[ -d gemsets/ ]] ; then
|
203
203
|
\mkdir -p "$rvm_gemsets_path"
|
204
|
-
for gemset_file in $(cd gemsets ; find \. -iname '*.gems' | sed 's/^\.\///') ; do
|
204
|
+
for gemset_file in $(builtin cd gemsets ; find \. -iname '*.gems' | sed 's/^\.\///') ; do
|
205
205
|
destination="$rvm_gemsets_path/$gemset_file"
|
206
206
|
destination_path="$(dirname "$destination")"
|
207
207
|
if [[ ! -s "$destination" ]] ; then
|
@@ -214,7 +214,7 @@ fi
|
|
214
214
|
spinner
|
215
215
|
if [[ -d patchsets/ ]] ; then
|
216
216
|
\mkdir -p "$rvm_patchsets_path"
|
217
|
-
for patchset_file in $(cd patchsets ; find \. -iname '*' | sed 's/^\.\///') ; do
|
217
|
+
for patchset_file in $(builtin cd patchsets ; find \. -iname '*' | sed 's/^\.\///') ; do
|
218
218
|
destination="$rvm_patchsets_path/$patchset_file"
|
219
219
|
destination_path="$(dirname "$destination")"
|
220
220
|
if [[ ! -s "$destination" ]] ; then
|
@@ -318,6 +318,7 @@ if [[ "$upgrade_flag" -eq 1 ]] ; then
|
|
318
318
|
printf "\n * 'rvm notes' tells you OS dependency packages for installing rubies."
|
319
319
|
printf "\n * If you encounter any issues with a ruby your best bet is to 'rvm remove X ; rvm install X' "
|
320
320
|
printf "\n * Gemset separator is '@' and will remain unless any rubies error using it."
|
321
|
+
printf "\n * If you wish to have the 'pretty colors' again, set 'export rvm_pretty_print=1' in ~/.rvmrc.\n"
|
321
322
|
printf "\n$(tput sgr0)\n"
|
322
323
|
check_rubyopt_conditions
|
323
324
|
printf "\nUpgrade of RVM in $rvm_path/ is complete.\n\n"
|
data/scripts/upgrade
CHANGED
@@ -4,7 +4,7 @@ unset GREP_OPTIONS
|
|
4
4
|
source "$rvm_scripts_path/base"
|
5
5
|
|
6
6
|
usage() {
|
7
|
-
echo "Usage: rvm upgrade prefix [
|
7
|
+
echo "Usage: rvm upgrade prefix [specific version]" >&2
|
8
8
|
echo "Upgrades the latest installed ruby with a given prefix (e.g. ree) to a new version." >&2
|
9
9
|
exit 1
|
10
10
|
}
|
@@ -13,7 +13,7 @@ confirm() {
|
|
13
13
|
printf "$1 (Y/n): "
|
14
14
|
local confirmation_response
|
15
15
|
read -r confirmation_response
|
16
|
-
[[ -z "$confirmation_response" ]] || echo
|
16
|
+
[[ -z "$confirmation_response" ]] || echo $confirmation_response | \grep -qi '^y\|^Y'
|
17
17
|
}
|
18
18
|
|
19
19
|
die_with_error() {
|
@@ -30,8 +30,7 @@ expand_existing_ruby() {
|
|
30
30
|
local ruby_name
|
31
31
|
while read -r ruby_name; do
|
32
32
|
if [[ "$ruby_name" != "$expanded_destination"* ]]; then
|
33
|
-
echo "$ruby_name"
|
34
|
-
return 0
|
33
|
+
echo "$ruby_name" ; return 0
|
35
34
|
fi
|
36
35
|
done < <("$rvm_scripts_path/list" strings | tr ' ' '\n' | sort -ur | \grep "^$prefix" | \grep -v '-head$' | head -n1)
|
37
36
|
return 1
|
@@ -48,24 +47,26 @@ upgrade_ruby() {
|
|
48
47
|
if [[ ! -d "$rvm_rubies_path/$expanded_destination" ]]; then
|
49
48
|
"$rvm_scripts_path/log" "info" "Installing new ruby $expanded_destination"
|
50
49
|
$rvm_bin_path/rvm install "$expanded_destination"
|
51
|
-
result="$?"
|
52
|
-
[[ "$result" -gt 0 ]] && die_with_error "Unable to install ruby $expanded_destination. Please install it manually to continue." "$result"
|
50
|
+
result="$?" ; [[ "$result" -gt 0 ]] && die_with_error "Unable to install ruby $expanded_destination. Please install it manually to continue." "$result"
|
53
51
|
fi
|
54
52
|
|
55
53
|
"$rvm_scripts_path/log" "info" "Migrating gems from $expanded_source to $expanded_destination"
|
56
54
|
"$rvm_scripts_path/migrate" "$expanded_source" "$expanded_destination"
|
57
|
-
result="$?"
|
58
|
-
[[ "$result" -gt 0 ]] && die_with_error "Error migrating gems." "$result"
|
55
|
+
result="$?" ; [[ "$result" -gt 0 ]] && die_with_error "Error migrating gems." "$result"
|
59
56
|
|
60
57
|
"$rvm_scripts_path/log" "info" "Upgrade complete!"
|
61
58
|
}
|
62
59
|
|
63
|
-
|
60
|
+
args=($*)
|
61
|
+
destination_ruby="${args[0]}"
|
62
|
+
source_ruby="${args[1]:-"$(expand_existing_ruby "$destination_ruby")"}"
|
63
|
+
args="$(echo ${args[@]:2}) " # Strip trailing / leading / extra spacing.
|
64
|
+
|
65
|
+
[[ -z "$source_ruby" ]] && usage
|
64
66
|
|
65
|
-
destination_ruby="$1"; shift
|
66
67
|
expanded_destination="$(expand_ruby_name "$destination_ruby")"
|
67
|
-
[[ -z "$expanded_destination" ]] && die_with_error "The destination ruby was not a valid ruby string."
|
68
68
|
|
69
|
-
|
69
|
+
[[ -z "$source_ruby" ]] && die_with_error "The Source ruby was not specified, a valid ruby string, or not found."
|
70
|
+
[[ -z "$expanded_destination" ]] && die_with_error "The destination ruby was not a valid ruby string, or not found."
|
70
71
|
|
71
72
|
upgrade_ruby
|
data/scripts/utility
CHANGED
@@ -2,24 +2,28 @@
|
|
2
2
|
|
3
3
|
__rvm_setup() {
|
4
4
|
# ZSH has 1 based array indexing, bash has 0 based.
|
5
|
-
if [[ -n "$ZSH_VERSION" ]] ; then
|
5
|
+
if [[ -n "${ZSH_VERSION:-""}" ]] ; then
|
6
6
|
__shell_array_start=1
|
7
7
|
# Set clobber for zsh users, for compatibility with bash's append operator ( >> file ) behavior
|
8
8
|
setopt | \grep -qs '^noclobber$'
|
9
9
|
rvm_zsh_clobber=$?
|
10
10
|
setopt clobber
|
11
11
|
else
|
12
|
-
__shell_array_start=0
|
12
|
+
__shell_array_start=0 # bash array indexes are 0 based.
|
13
13
|
fi ; export __shell_array_start
|
14
14
|
}
|
15
15
|
|
16
16
|
__rvm_teardown() {
|
17
|
-
|
17
|
+
declare rvm_dump_environment_flag=${rvm_dump_environment_flag:-0}
|
18
|
+
declare rvm_clang_flag=${rvm_clang_flag:-0}
|
19
|
+
declare rvm_prior_cc=${rvm_prior_cc:-""}
|
20
|
+
|
21
|
+
if [[ -n "${ZSH_VERSION:-""}" ]] ; then
|
18
22
|
if [[ "$rvm_zsh_clobber" -eq 0 ]] ; then
|
19
23
|
setopt noclobber
|
20
24
|
fi ; unset rvm_zsh_clobber
|
21
25
|
else
|
22
|
-
:
|
26
|
+
: # currently we are not doing any option setting for bash.
|
23
27
|
fi
|
24
28
|
# Ruby strings are scoped to their action.
|
25
29
|
# Hence, we ensure we remove them at in
|
@@ -37,39 +41,53 @@ __rvm_teardown() {
|
|
37
41
|
|
38
42
|
unset rvm_ruby_strings
|
39
43
|
|
40
|
-
[[
|
44
|
+
[[ $rvm_dump_environment_flag -eq 1 ]] && __rvm_dump_environment
|
41
45
|
|
46
|
+
return 0
|
42
47
|
}
|
43
48
|
|
49
|
+
# Dump the current environment to a file.
|
44
50
|
__rvm_dump_environment() {
|
45
51
|
# Note: This assumes that there is a ','
|
46
52
|
local dump_environment_file="${rvm_dump_environment_flag/,*/}"
|
47
53
|
local dump_environment_type="${rvm_dump_environment_flag/*,/}"
|
48
54
|
if [[ -n "$dump_environment_file" && -n "$dump_environment_type" ]]; then
|
49
|
-
if [[ "$dump_environment_type" == "atheis"* ]]; then
|
50
|
-
|
55
|
+
if [[ "$dump_environment_type" == "atheis"* ]] && [[ -f "$dump_environment_file" ]] ; then
|
56
|
+
# TODO: Query Darcy about the ln.
|
57
|
+
\rm -f "$dump_environment_file" && ln -s /dev/null "$dump_environment_file" >/dev/null 2>&1
|
51
58
|
else
|
52
59
|
"$rvm_scripts_path/environment-convertor" "$dump_environment_type" "$(__rvm_environment_identifier)" > "$dump_environment_file"
|
53
|
-
[[ "$?" -gt 0 ]] &&
|
60
|
+
if [[ "$?" -gt 0 ]] && [[ -f "$dump_environment_file" ]] ; then
|
61
|
+
\rm -f "$dump_environment_file"
|
62
|
+
fi
|
54
63
|
fi
|
55
64
|
fi ; unset rvm_dump_environment_flag
|
65
|
+
return 0
|
56
66
|
}
|
57
67
|
|
58
68
|
# Return a list of directories under a given base path.
|
59
69
|
# Derived from rvm_ruby_string.
|
60
70
|
__rvm_ruby_string_paths_under() {
|
61
|
-
local
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
71
|
+
local path="$1"
|
72
|
+
local path_parts="${rvm_ruby_string//-/ }"
|
73
|
+
|
74
|
+
while true ; do
|
75
|
+
echo "$path/$path_parts" | sed -e 's# #/#g' -e 's#/$##g'
|
76
|
+
[[ -z "$path_parts" ]] && break
|
77
|
+
path_parts="$(echo "$path_parts" | awk '{$NF=""; print}' | __rvm_strip)"
|
66
78
|
done
|
79
|
+
|
80
|
+
return 0
|
67
81
|
}
|
68
82
|
|
69
83
|
# Query the rvm key-value database for a specific key
|
70
84
|
# Allow overrides from user specifications in $rvm_config_path/user
|
71
85
|
__rvm_db() {
|
72
|
-
key
|
86
|
+
local value="" key="" variable=""
|
87
|
+
|
88
|
+
key=${1:-""}
|
89
|
+
variable=${2:-""}
|
90
|
+
|
73
91
|
if [[ -f "$rvm_config_path/user" ]] ; then
|
74
92
|
value="$($rvm_scripts_path/db "$rvm_config_path/user" "$key")"
|
75
93
|
fi
|
@@ -79,13 +97,14 @@ __rvm_db() {
|
|
79
97
|
fi
|
80
98
|
|
81
99
|
if [[ -n "$value" ]] ; then
|
82
|
-
if [[ -z $variable ]] ; then
|
100
|
+
if [[ -z "$variable" ]] ; then
|
83
101
|
echo $value
|
84
102
|
else
|
85
103
|
eval "$variable='$value'"
|
86
104
|
fi
|
87
105
|
fi
|
88
|
-
|
106
|
+
|
107
|
+
return 0
|
89
108
|
}
|
90
109
|
|
91
110
|
is_a_function() { type $1 | head -n 1 | \grep -q "function" ; }
|
@@ -100,15 +119,16 @@ __rvm_quote_args() {
|
|
100
119
|
fi
|
101
120
|
done
|
102
121
|
echo "$quoted_string" | sed -e 's/^ *//g' -e 's/ *$//g'
|
122
|
+
return 0
|
103
123
|
}
|
104
124
|
|
105
125
|
__rvm_quote_args_with_shift() {
|
106
126
|
local shift_value="$1"; shift
|
107
127
|
while [[ "$shift_value" -gt 0 && "$#" -gt 0 ]]; do
|
108
|
-
shift
|
109
|
-
let shift_value=shift_value-1
|
128
|
+
shift ; ((shift_value--))
|
110
129
|
done
|
111
130
|
__rvm_quote_args "$@"
|
131
|
+
return 0
|
112
132
|
}
|
113
133
|
|
114
134
|
__rvm_warn_on_rubyopt() {
|
@@ -121,17 +141,11 @@ __rvm_warn_on_rubyopt() {
|
|
121
141
|
}
|
122
142
|
|
123
143
|
__rvm_strings() {
|
124
|
-
|
125
|
-
for rvm_ruby_string in $(echo $rvm_ruby_args) ; do
|
126
|
-
|
127
|
-
if [[ $? -gt 0 ]] ; then
|
128
|
-
return 1
|
129
|
-
else
|
130
|
-
results="$results $(__rvm_select ; echo $rvm_ruby_string)"
|
131
|
-
fi
|
144
|
+
local strings=""
|
145
|
+
for rvm_ruby_string in $(echo ${rvm_ruby_args:-$rvm_ruby_string}) ; do
|
146
|
+
strings="$strings $(__rvm_select ; echo $rvm_ruby_string)"
|
132
147
|
done
|
133
|
-
echo $
|
134
|
-
unset results
|
148
|
+
echo $strings
|
135
149
|
return 0
|
136
150
|
}
|
137
151
|
|
@@ -168,45 +182,71 @@ __rvm_remove_rvm_from_path() {
|
|
168
182
|
|
169
183
|
# Run a specified command and log it.
|
170
184
|
__rvm_run() {
|
171
|
-
log_file_name="$1"
|
185
|
+
local log_file_name="$1"
|
186
|
+
local command="$2"
|
187
|
+
local message="$3"
|
188
|
+
|
172
189
|
if [[ -z "$rvm_ruby_log_path" ]] ; then rvm_ruby_log_path="$rvm_log_path" ; fi
|
190
|
+
|
173
191
|
if [[ -n "$message" ]] ; then "$rvm_scripts_path/log" "info" "$message" ; fi
|
192
|
+
|
174
193
|
if [[ -n "$rvm_debug_flag" ]] ; then
|
175
194
|
"$rvm_scripts_path/log" "debug" "Executing: $command"
|
176
195
|
fi
|
177
196
|
|
178
197
|
\mkdir -p "$(dirname "$rvm_ruby_log_path/$log_file_name.log")"
|
198
|
+
|
179
199
|
\touch "$rvm_ruby_log_path/$log_file_name.log" "$rvm_ruby_log_path/$log_file_name.error.log" # for zsh :(
|
180
|
-
|
200
|
+
|
201
|
+
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $command" | \tee "$rvm_ruby_log_path/$log_file_name.log" >> "$rvm_ruby_log_path/$log_file_name.error.log"
|
202
|
+
|
181
203
|
if [[ -z "$rvm_niceness" ]] || [[ "0" = "$rvm_niceness" ]] ; then
|
182
204
|
eval "$command" >> "$rvm_ruby_log_path/$log_file_name.log" 2>> "$rvm_ruby_log_path/$log_file_name.error.log"
|
183
205
|
else
|
184
206
|
eval "nice -n $rvm_niceness $command" >> $rvm_ruby_log_path/$log_file_name.log 2>> $rvm_ruby_log_path/$log_file_name.error.log
|
207
|
+
fi ; local result=$?
|
208
|
+
|
209
|
+
if [[ $result -gt 0 ]] ; then
|
210
|
+
"$rvm_scripts_path/log" "error" "Error running '$command', please check $rvm_ruby_log_path/$log_file_name*.log" ; __rvm_pushpop
|
185
211
|
fi
|
186
|
-
|
187
|
-
|
212
|
+
|
213
|
+
return $result
|
188
214
|
}
|
189
215
|
|
190
216
|
# Runs a command in a given env.
|
191
217
|
__rvm_run_with_env() {
|
192
|
-
log_file_name="$1"
|
218
|
+
local log_file_name="${1:-""}"
|
219
|
+
local env_name="${2:-""}"
|
220
|
+
local command="${3:-""}"
|
221
|
+
local message="${4:-""}"
|
222
|
+
|
193
223
|
if [[ -z "$env_name" ]]; then env_name="$(__rvm_environment_identifier)"; fi
|
224
|
+
|
194
225
|
if [[ -z "$rvm_ruby_log_path" ]] ; then rvm_ruby_log_path="$rvm_log_path" ; fi
|
226
|
+
|
195
227
|
if [[ -n "$message" ]] ; then "$rvm_scripts_path/log" "info" "$message" ; fi
|
228
|
+
|
196
229
|
if [[ -n "$rvm_debug_flag" ]] ; then
|
197
230
|
"$rvm_scripts_path/log" "debug" "Executing: $command in environment "$env_name""
|
198
231
|
fi
|
199
232
|
|
200
233
|
\mkdir -p "$(dirname "$rvm_ruby_log_path/$log_file_name.log")"
|
234
|
+
|
201
235
|
\touch "$rvm_ruby_log_path/$log_file_name.log" "$rvm_ruby_log_path/$log_file_name.error.log" # for zsh :(
|
236
|
+
|
202
237
|
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $command # under $env_name" | tee "$rvm_ruby_log_path/$log_file_name.log" >> "$rvm_ruby_log_path/$log_file_name.error.log"
|
203
|
-
|
238
|
+
|
239
|
+
if [[ -z "$rvm_niceness" || "0" = "$rvm_niceness" ]] ; then
|
204
240
|
eval "__rvm_with_env '$env_name' '$command'" >> "$rvm_ruby_log_path/$log_file_name.log" 2>> "$rvm_ruby_log_path/$log_file_name.error.log"
|
205
241
|
else
|
206
242
|
eval "nice -n $rvm_niceness __rvm_with_env '$env_name' '$command'" >> $rvm_ruby_log_path/$log_file_name.log 2>> $rvm_ruby_log_path/$log_file_name.error.log
|
243
|
+
fi ; result=$?
|
244
|
+
|
245
|
+
if [[ $result -gt 0 ]] ; then
|
246
|
+
"$rvm_scripts_path/log" "error" "Error running '$command' under $env_name, please check $rvm_ruby_log_path/$log_file_name*.log" ; __rvm_pushpop
|
207
247
|
fi
|
208
|
-
|
209
|
-
|
248
|
+
|
249
|
+
return $result
|
210
250
|
}
|
211
251
|
|
212
252
|
# Unset both rvm variables as well as ruby-specific variables
|
@@ -214,7 +254,7 @@ __rvm_run_with_env() {
|
|
214
254
|
__rvm_cleanse_variables() {
|
215
255
|
__rvm_unset_ruby_variables
|
216
256
|
|
217
|
-
if [[
|
257
|
+
if [[ ${rvm_sticky_flag:-0} -eq 1 ]] ; then export rvm_gemset_name ; else unset rvm_gemset_name ; fi
|
218
258
|
|
219
259
|
unset rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_url 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_ruby_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
|
220
260
|
}
|
@@ -226,27 +266,23 @@ __rvm_unset_ruby_variables() {
|
|
226
266
|
|
227
267
|
# Usage: __rvm_with_env 'env-name' 'command'
|
228
268
|
__rvm_with_env() {
|
229
|
-
|
230
|
-
|
231
|
-
# Subshells!
|
232
|
-
(
|
233
|
-
source "$rvm_scripts_path/rvm"
|
234
|
-
rvm "$rvm_env_args" use $1 && eval "$rvm_env_command"
|
235
|
-
)
|
236
|
-
unset rvm_env_args rvm_env_command
|
269
|
+
local environment_id="$1" command="$2"
|
270
|
+
( rvm use "$environment_id" ; eval "$command" )
|
237
271
|
}
|
238
272
|
|
239
273
|
# Returns the first 1.8.7-compatible (partly) ruby for use
|
240
274
|
# with things like rbx etc which require a ruby be installed.
|
241
275
|
__rvm_18_compat_ruby() {
|
242
|
-
rubies=""
|
276
|
+
local rubies=""
|
243
277
|
for ruby_name in $(\ls "$rvm_rubies_path"); do
|
244
278
|
if [[ ! -L "$rvm_rubies_path/$ruby_name" ]] && [[ "$ruby_name" =~ 1.8. || "$ruby_name" =~ rbx- || "$ruby_name" =~ ree- ]] ; then
|
245
279
|
rubies="$rubies $ruby_name"
|
246
280
|
fi
|
247
281
|
done; unset ruby_name
|
282
|
+
|
248
283
|
echo "$rubies" | sed 's/^ //' | \tr ' ' '\n' | sort | tail -n1
|
249
|
-
|
284
|
+
|
285
|
+
return 0
|
250
286
|
}
|
251
287
|
|
252
288
|
__rvm_ensure_has_18_compat_ruby() {
|
@@ -258,23 +294,32 @@ __rvm_ensure_has_18_compat_ruby() {
|
|
258
294
|
"$rvm_scripts_path/log" "fail" "Please install it manually (or a compatible alternative) to proceed."
|
259
295
|
compat_result=1
|
260
296
|
fi ; unset original_ruby
|
297
|
+
# TODO: Why are we unsetting original_ruby here
|
261
298
|
return $compat_result
|
262
299
|
fi
|
300
|
+
|
301
|
+
return 0
|
263
302
|
}
|
264
303
|
|
265
304
|
__rvm_inherit_trace_flag() {
|
266
305
|
if [[ -n "$rvm_trace_flag" ]]; then
|
267
306
|
set -x ; export rvm_trace_flag
|
268
307
|
fi
|
308
|
+
return 0
|
269
309
|
}
|
270
310
|
|
271
311
|
# Cleans up temp folders for a given prefix,
|
272
312
|
# typically the current process id.
|
273
313
|
__rvm_cleanup_temp_for() {
|
274
|
-
|
314
|
+
local prefix="$1"
|
315
|
+
|
316
|
+
[[ -z "$prefix" ]] && return 1
|
317
|
+
|
275
318
|
if [[ -d "$rvm_tmp_path/" ]]; then
|
276
|
-
\rm -rf "$rvm_tmp_path/$
|
277
|
-
fi
|
319
|
+
\rm -rf "$rvm_tmp_path/$prefix"* >/dev/null 2>&1
|
320
|
+
fi
|
321
|
+
|
322
|
+
exit
|
278
323
|
}
|
279
324
|
|
280
325
|
__rvm_cleanup_temp_on_exit() {
|
@@ -283,7 +328,7 @@ __rvm_cleanup_temp_on_exit() {
|
|
283
328
|
|
284
329
|
__rvm_set_rvmrc() {
|
285
330
|
if [[ "$HOME" != "$PWD" ]] ; then
|
286
|
-
if [[
|
331
|
+
if [[ ${rvm_verbose_flag:-0} -eq 1 ]] ; then flags="use " ; fi
|
287
332
|
|
288
333
|
if [[ -s .rvmrc ]] ; then
|
289
334
|
mv .rvmrc .rvmrc.$(date +%m.%d.%Y-%H:%M:%S)
|
@@ -291,6 +336,7 @@ __rvm_set_rvmrc() {
|
|
291
336
|
fi
|
292
337
|
|
293
338
|
local identifier=$(__rvm_environment_identifier)
|
339
|
+
|
294
340
|
printf "if [[ -n \"\$rvm_environments_path\" && -s \"\$rvm_environments_path/$identifier\" ]] ; then\n \\. \"\$rvm_environments_path/$identifier\"" > .rvmrc
|
295
341
|
printf "\nelse\n rvm --create $flags \"$identifier\"\nfi" >> .rvmrc
|
296
342
|
|
@@ -300,7 +346,9 @@ __rvm_set_rvmrc() {
|
|
300
346
|
fi
|
301
347
|
}
|
302
348
|
__rvm_load_rvmrc() {
|
303
|
-
|
349
|
+
rvm_ignore_rvmrc=${rvm_ignore_rvmrc:-0}
|
350
|
+
[[ $rvm_ignore_rvmrc -eq 1 ]] && return 0
|
351
|
+
|
304
352
|
for rvmrc in /etc/rvmrc $HOME/.rvmrc ; do
|
305
353
|
if [[ -f "$rvmrc" ]] ; then
|
306
354
|
if \grep -q '^\s*rvm .*$' $rvmrc ; then
|
@@ -311,6 +359,8 @@ __rvm_load_rvmrc() {
|
|
311
359
|
fi
|
312
360
|
fi
|
313
361
|
done
|
362
|
+
|
363
|
+
return 0
|
314
364
|
}
|
315
365
|
|
316
366
|
# Wrap the specified ruby code file in a Benchmark.bmbm block and execute it.
|
@@ -325,14 +375,16 @@ __rvm_benchmark() {
|
|
325
375
|
rvm_action="ruby"
|
326
376
|
if [[ -n "$rvm_debug_flag" ]] ; then printf "\n$rvm_tmp_path/$$.rb:\n$(cat $rvm_tmp_path/$$.rb)" ; fi
|
327
377
|
# Override ruby string stuff, pass through.
|
328
|
-
old_rvm_ruby_string=$rvm_ruby_string
|
378
|
+
local old_rvm_ruby_string=$rvm_ruby_string
|
379
|
+
# TODO: We can likely do this in a subshell in order to preserve the original environment?
|
329
380
|
unset rvm_ruby_string
|
330
381
|
export rvm_ruby_strings
|
331
382
|
"$rvm_scripts_path/set" "$rvm_action" $rvm_ruby_args
|
332
383
|
result=$?
|
333
384
|
# Restore the state pre-sets.
|
334
385
|
[[ -n "$old_rvm_ruby_string" ]] && rvm_ruby_string=$old_rvm_ruby_string
|
335
|
-
|
386
|
+
|
387
|
+
return $result
|
336
388
|
}
|
337
389
|
|
338
390
|
# Loop over the currently installed rubies and refresh their binscripts.
|
@@ -344,12 +396,14 @@ __rvm_bin_scripts() {
|
|
344
396
|
__rvm_bin_script
|
345
397
|
fi
|
346
398
|
done
|
399
|
+
return 0
|
347
400
|
}
|
348
401
|
|
349
402
|
# Write the bin/ wrapper script for currently selected ruby.
|
350
403
|
# TODO: Adjust binscript to be able to handle all rubies not just the standard interpreteres.
|
351
404
|
__rvm_bin_script() {
|
352
405
|
"$rvm_scripts_path/wrapper" "$rvm_ruby_string"
|
406
|
+
return $?
|
353
407
|
}
|
354
408
|
|
355
409
|
# Add bin path if not present
|
@@ -358,18 +412,20 @@ __rvm_conditionally_add_bin_path() {
|
|
358
412
|
PATH="${rvm_bin_path}:$PATH"
|
359
413
|
builtin hash -r
|
360
414
|
fi
|
415
|
+
return 0
|
361
416
|
}
|
362
417
|
|
363
418
|
# Reset any rvm gathered information about the system and its state.
|
364
419
|
# rvm will refresh the stored information the next time it is called after reset.
|
365
420
|
__rvm_reset() {
|
366
|
-
__rvm_remove_rvm_from_path
|
367
|
-
|
368
|
-
export PATH
|
421
|
+
__rvm_remove_rvm_from_path ; __rvm_conditionally_add_bin_path ; export PATH
|
422
|
+
|
369
423
|
builtin hash -r
|
370
424
|
|
371
|
-
|
372
|
-
|
425
|
+
local flag=""
|
426
|
+
for flag in default passenger editor ; do
|
427
|
+
\rm -f "$rvm_bin_path"/${flag}_*
|
428
|
+
done
|
373
429
|
|
374
430
|
for file in system default ; do
|
375
431
|
[[ -f "${rvm_path}/${file}" ]] && \rm -f "$rvm_path/${file}"
|
@@ -386,13 +442,17 @@ __rvm_reset() {
|
|
386
442
|
done ; unset system_config variable
|
387
443
|
|
388
444
|
\rm -f $rvm_bin_path/ruby $rvm_bin_path/gem $rvm_bin_path/rake $rvm_bin_path/irb $rvm_bin_path/default*
|
445
|
+
|
446
|
+
return 0
|
389
447
|
}
|
390
448
|
|
391
449
|
# Implode removes the entire rvm installation under $rvm_path.
|
392
450
|
__rvm_implode() {
|
393
451
|
while : ; do
|
394
452
|
"$rvm_scripts_path/log" "warn" "Are you SURE you wish for rvm to implode? This will remove $rvm_path ? (type 'yes' or 'no')"
|
453
|
+
|
395
454
|
read response
|
455
|
+
|
396
456
|
if [[ "yes" = "$response" ]] ; then
|
397
457
|
if [[ "/" = "$rvm_path" ]] ; then
|
398
458
|
"$rvm_scripts_path/log" "error" "remove '/' ?!... Ni!"
|
@@ -411,16 +471,21 @@ __rvm_implode() {
|
|
411
471
|
break
|
412
472
|
fi
|
413
473
|
done
|
474
|
+
|
475
|
+
return 0
|
414
476
|
}
|
415
477
|
|
416
478
|
# Output the current ruby's rvm source path.
|
417
479
|
__rvm_source_dir() {
|
418
480
|
if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select ; fi
|
481
|
+
|
419
482
|
if [[ -z "$rvm_ruby_src_path" ]] ; then
|
420
483
|
"$rvm_scripts_path/log" "fail" "No source directory exists for the default implementation."
|
421
484
|
else
|
422
485
|
echo "$rvm_ruby_src_path"
|
423
486
|
fi
|
487
|
+
|
488
|
+
return 0
|
424
489
|
}
|
425
490
|
|
426
491
|
# Initialize rvm, ensuring that the path and directories are as expected.
|
@@ -428,36 +493,43 @@ __rvm_initialize() {
|
|
428
493
|
rvm_ruby_load_path="."
|
429
494
|
rvm_ruby_require=""
|
430
495
|
|
431
|
-
__rvm_clean_path
|
432
|
-
|
433
|
-
__rvm_conditionally_add_bin_path
|
434
|
-
export PATH
|
496
|
+
__rvm_clean_path ; __rvm_conditionally_add_bin_path ; export PATH
|
435
497
|
|
436
498
|
\mkdir -p "$rvm_src_path" "$rvm_bin_path" "$rvm_archives_path" "$rvm_gems_path" "$rvm_tmp_path" "$rvm_repo_path"
|
499
|
+
|
500
|
+
return 0
|
437
501
|
}
|
438
502
|
|
439
503
|
# Update rubygems or binscripts based on CLI selection.
|
440
504
|
__rvm_update() {
|
441
505
|
__rvm_pushpop $rvm_path
|
442
|
-
|
506
|
+
|
507
|
+
if [[ ${rvm_head_flag:-0} -eq 1 || ${rvm_self_flag:-0} -eq 1 || "update" = "${rvm_action:-""}" || ${rvm_update_flag:-0} -eq 1 ]] ; then
|
443
508
|
__rvm_version
|
444
509
|
__rvm_update_rvm
|
445
510
|
fi
|
446
|
-
|
511
|
+
|
512
|
+
[[ ${rvm_bin_flag:-0} -eq 1 ]] && __rvm_bin_scripts
|
513
|
+
|
447
514
|
# Update to the latest rubygems.
|
448
|
-
[[
|
515
|
+
[[ ${rvm_rubygems_flag:-0} -eq 1 ]] && "$rvm_scripts_path/rubygems" current
|
449
516
|
|
450
517
|
unset rvm_update_flag rvm_action rvm_self_flag rvm_ruby_revision rvm_bin_flag rvm_rubygems_flag
|
518
|
+
|
451
519
|
__rvm_pushpop
|
520
|
+
|
521
|
+
return 0
|
452
522
|
}
|
453
523
|
|
454
524
|
# Update rvm using rubygems
|
455
525
|
# If --head was specified, update from git repository master branch.
|
456
526
|
__rvm_update_rvm() {
|
527
|
+
|
457
528
|
\mkdir -p "$rvm_src_path"
|
529
|
+
|
458
530
|
__rvm_pushpop "$rvm_src_path"
|
459
531
|
|
460
|
-
if [[
|
532
|
+
if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then
|
461
533
|
if [[ -d "$rvm_src_path/rvm/.git" ]] ; then
|
462
534
|
builtin cd "$rvm_src_path/rvm/" && git pull origin master && ./scripts/install
|
463
535
|
else
|
@@ -474,34 +546,50 @@ __rvm_update_rvm() {
|
|
474
546
|
fi
|
475
547
|
|
476
548
|
__rvm_pushpop
|
549
|
+
|
477
550
|
rvm_hook="after_update" ; source "$rvm_scripts_path/hook"
|
551
|
+
|
552
|
+
return 0
|
478
553
|
}
|
479
554
|
|
480
555
|
__rvm_reboot() {
|
481
556
|
"$rvm_scripts_path/log" "warn" "Do you wish to reboot rvm? ('yes', or 'no')"
|
557
|
+
|
558
|
+
local response="no"
|
559
|
+
|
482
560
|
read response
|
561
|
+
|
483
562
|
if [[ "yes" = "$response" ]] ; then
|
484
563
|
builtin cd $rvm_path
|
564
|
+
|
485
565
|
__rvm_reset
|
566
|
+
|
486
567
|
mv "$rvm_path/archives" "$HOME/.archives"
|
568
|
+
|
487
569
|
if [[ "/" = "$rvm_path" ]] ; then
|
488
570
|
"$rvm_scripts_path/log" "error" "remove '/' ?!... NO!"
|
489
571
|
else
|
490
572
|
if [[ -d "$rvm_path" ]] ; then \rm -rf "$rvm_path/" ; fi
|
491
573
|
fi
|
574
|
+
|
492
575
|
gem install rvm $rvm_gem_options
|
576
|
+
|
493
577
|
__rvm_update_rvm
|
494
|
-
|
578
|
+
|
579
|
+
source "$rvm_path/scripts/rvm"
|
495
580
|
else
|
496
581
|
"$rvm_scripts_path/log" "info" "Carry on then..."
|
497
|
-
fi
|
582
|
+
fi
|
583
|
+
|
584
|
+
return 0
|
498
585
|
}
|
499
586
|
|
500
587
|
# Create the irbrc for the currently selected ruby installation.
|
501
588
|
__rvm_irbrc() {
|
502
|
-
if [[ -d "$rvm_ruby_home"
|
589
|
+
if [[ -d "$rvm_ruby_home" && ! -s "$rvm_ruby_irbrc" ]] ; then
|
503
590
|
\cp "$rvm_scripts_path/irbrc" "$rvm_ruby_irbrc"
|
504
591
|
fi
|
592
|
+
return $?
|
505
593
|
}
|
506
594
|
|
507
595
|
# Push or Pop a directory based on zero or one directory argument provided.
|
@@ -511,6 +599,8 @@ __rvm_pushpop() {
|
|
511
599
|
else
|
512
600
|
pushd "$1" > /dev/null 2>&1
|
513
601
|
fi
|
602
|
+
|
603
|
+
return $?
|
514
604
|
}
|
515
605
|
|
516
606
|
# Save or restore the rvm's state. This is a toggle action.
|
@@ -530,20 +620,33 @@ __rvm_state() {
|
|
530
620
|
__rvm_use
|
531
621
|
unset rvm_state
|
532
622
|
fi
|
623
|
+
|
624
|
+
return 0
|
533
625
|
}
|
534
626
|
|
535
627
|
# Output an inspection of selected 'binary' scripts, based on CLI selection.
|
536
628
|
__rvm_inspect() {
|
629
|
+
rvm_shebang_flag=${rvm_shebang_flag:-0}
|
630
|
+
rvm_env_flag=${rvm_env_flag:-0}
|
631
|
+
rvm_path_flag=${rvm_path_flag:-0}
|
632
|
+
rvm_head_flag=${rvm_head_flag:-0}
|
633
|
+
rvm_tail_flag=${rvm_tail_flag:-0}
|
634
|
+
rvm_all_flag=${rvm_all_flag:-0}
|
635
|
+
|
537
636
|
for binary in $rvm_ruby_args ; do
|
538
637
|
actual_file="$(command -v $binary)"
|
638
|
+
|
539
639
|
"$rvm_scripts_path/log" "info" "$actual_file:"
|
540
|
-
|
541
|
-
if [[ -
|
542
|
-
if [[ -
|
543
|
-
if [[ -
|
544
|
-
if [[ -
|
545
|
-
if [[ -
|
640
|
+
|
641
|
+
if [[ $rvm_shebang_flag -eq 1 ]] ; then head -n 1 < "$actual_file" ; fi
|
642
|
+
if [[ $rvm_env_flag -eq 1 ]] ; then awk '/ENV/' < "$actual_file" ; fi
|
643
|
+
if [[ $rvm_path_flag -eq 1 ]] ; then awk '/PATH/' < "$actual_file" ; fi
|
644
|
+
if [[ $rvm_head_flag -eq 1 ]] ; then head -n 5 < "$actual_file" ; fi
|
645
|
+
if [[ $rvm_tail_flag -eq 1 ]] ; then tail -n 5 < "$actual_file" ; fi
|
646
|
+
if [[ $rvm_all_flag -eq 1 ]] ; then cat $actual_file ; fi
|
546
647
|
done
|
648
|
+
|
649
|
+
return 0
|
547
650
|
}
|
548
651
|
|
549
652
|
# Attempt to override the Darwin build settings for rubies
|
@@ -577,6 +680,8 @@ __rvm_make_flags() {
|
|
577
680
|
# CXXFLAGS="-mmacosx-version-min="$(sw_vers -productVersion | awk -F'.' '{print $1"."$2}')" -isysroot /Developer/SDKs/$rvm_sdk " ; export CXXFLAGS
|
578
681
|
fi
|
579
682
|
fi
|
683
|
+
|
684
|
+
return 0
|
580
685
|
}
|
581
686
|
|
582
687
|
__rvm_mono_env() {
|
@@ -587,23 +692,35 @@ __rvm_mono_env() {
|
|
587
692
|
export PKG_CONFIG_PATH="$rvm_usr_path/lib/pkgconfig:$PKG_CONFIG_PATH"
|
588
693
|
PATH="$rvm_usr_path/bin:$PATH"
|
589
694
|
builtin hash -r
|
695
|
+
|
696
|
+
return 0
|
590
697
|
}
|
591
698
|
|
592
699
|
__rvm_become() {
|
593
|
-
|
700
|
+
local string="$1"
|
701
|
+
|
702
|
+
[[ -n "$string" ]] && rvm_ruby_string="$string"
|
703
|
+
|
594
704
|
{ __rvm_ruby_string && __rvm_select && __rvm_use; } > /dev/null 2>&1
|
705
|
+
|
706
|
+
return 0
|
595
707
|
}
|
596
708
|
|
597
709
|
__rvm_ensure_has_environment_files() {
|
598
710
|
local environment_identifier="$(__rvm_environment_identifier)"
|
711
|
+
|
599
712
|
local file_name="${rvm_environments_path}/$environment_identifier"
|
600
713
|
|
601
714
|
if [[ ! -s "$file_name" ]] ; then
|
602
715
|
\mkdir -p "${rvm_environments_path}"
|
716
|
+
|
603
717
|
echo "export PATH=\"${rvm_ruby_gem_home}/bin:${rvm_ruby_global_gems_path}/bin:${rvm_ruby_home}/bin:${rvm_bin_path}:\$PATH\"" > "$file_name"
|
718
|
+
|
604
719
|
for variable in RUBY_VERSION GEM_HOME GEM_PATH BUNDLE_PATH MY_RUBY_HOME IRBRC rvm_ruby_string rvm_gemset_name MAGLEV_HOME ; do
|
605
720
|
eval "export $variable"
|
721
|
+
|
606
722
|
eval "value=\$${variable}"
|
723
|
+
|
607
724
|
if [[ -n "$value" ]] ; then
|
608
725
|
printf "${variable}='$value'\nexport ${variable}\n" >> "$file_name"
|
609
726
|
else
|
@@ -612,28 +729,37 @@ __rvm_ensure_has_environment_files() {
|
|
612
729
|
done ; unset variable value
|
613
730
|
fi ; unset file_name
|
614
731
|
|
732
|
+
local directory_name=""
|
733
|
+
local wrapper_identifier=""
|
615
734
|
# Next, ensure we have default wrapper files. Also, prevent it from recursing.
|
616
|
-
if [[
|
735
|
+
if [[ ${rvm_creating_default_wrappers:-0} -eq 1 ]]; then
|
617
736
|
# We need to generate wrappers for both the default gemset and the global gemset.
|
618
737
|
for wrapper_identifier in "$environment_identifier" "${environment_identifier}@global" ; do
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
738
|
+
|
739
|
+
rvm_creating_default_wrappers=1
|
740
|
+
|
741
|
+
directory_name="$rvm_wrappers_path/$wrapper_identifier"
|
742
|
+
|
743
|
+
if [[ ! -L "$directory_name" && ! -d "$directory_name" ]]; then
|
744
|
+
\mkdir -p "$directory_name"
|
745
|
+
|
746
|
+
"$rvm_scripts_path/wrapper" "$wrapper_identifier" &> /dev/null
|
747
|
+
fi
|
748
|
+
rvm_creating_default_wrappers=0
|
749
|
+
done
|
627
750
|
fi
|
751
|
+
return 0
|
628
752
|
}
|
629
753
|
|
630
754
|
# Strip whitespace and normalize it all.
|
631
755
|
__rvm_strip() {
|
632
756
|
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/[[:space:]]\{1,\}/ /g'
|
757
|
+
return $?
|
633
758
|
}
|
634
759
|
|
635
760
|
__rvm_using_gemset_globalcache() {
|
636
761
|
"$rvm_scripts_path/db" "$rvm_config_path/user" "use_gemset_globalcache" | \grep -q '^true$'
|
762
|
+
return $?
|
637
763
|
}
|
638
764
|
|
639
765
|
__rvm_current_gemcache_dir() {
|
@@ -642,62 +768,85 @@ __rvm_current_gemcache_dir() {
|
|
642
768
|
else
|
643
769
|
echo "${rvm_ruby_gem_home:-"$GEM_HOME"}/cache"
|
644
770
|
fi
|
771
|
+
return 0
|
645
772
|
}
|
646
773
|
|
647
774
|
__rvm_Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything() {
|
648
775
|
for index in {1..750} ; do sleep 0.25 ; echo -n '.' ; done ; printf "%d" 0x2A ; echo
|
776
|
+
return 0
|
649
777
|
}
|
650
778
|
|
651
779
|
__rvm_ultimate_question() {
|
652
|
-
printf "
|
653
|
-
|
654
|
-
|
655
|
-
|
780
|
+
printf "
|
781
|
+
I do not know the Ultimate Question,
|
782
|
+
however I can help you build a more
|
783
|
+
powerful Ruby which can compute the
|
784
|
+
Ultimate Question.
|
785
|
+
"
|
786
|
+
return 0
|
656
787
|
}
|
657
788
|
|
658
789
|
__rvm_load_env_file() {
|
659
|
-
|
790
|
+
local string="$1"
|
791
|
+
if [[ -f "$rvm_environments_path/$string" ]]; then
|
660
792
|
# Restore the path to it's state minus rvm
|
661
793
|
__rvm_remove_rvm_from_path
|
662
|
-
|
794
|
+
|
795
|
+
# source the environment file
|
796
|
+
\. "$rvm_environments_path/$string"
|
797
|
+
|
798
|
+
# clear the PATH cache
|
663
799
|
builtin hash -r
|
800
|
+
elif [[ -n "$string" ]] ; then
|
801
|
+
rvm "$string"
|
664
802
|
else
|
665
|
-
|
803
|
+
: # TODO: This should have some error handling in the context.
|
666
804
|
fi
|
805
|
+
return 0
|
667
806
|
}
|
668
807
|
|
669
808
|
__rvm_md5_for() {
|
670
809
|
if command -v md5 > /dev/null; then
|
671
810
|
echo "$1" | md5
|
672
|
-
|
811
|
+
elif command -v md5sum > /dev/null ; then
|
673
812
|
echo "$1" | md5sum | awk '{print $1}'
|
813
|
+
else
|
814
|
+
"$rvm_path/scripts/log" "error" "Neither md5 nor md5sum were found in the PATH"
|
815
|
+
return 1
|
674
816
|
fi
|
817
|
+
|
818
|
+
return 0
|
675
819
|
}
|
676
820
|
|
677
821
|
__rvm_rvmrc_key() {
|
678
822
|
__rvm_md5_for "$1"
|
823
|
+
return $?
|
679
824
|
}
|
680
825
|
|
681
826
|
__rvm_reset_rvmrc_trust() {
|
682
827
|
touch "$rvm_config_path/rvmrcs"
|
683
828
|
"$rvm_scripts_path/db" "$rvm_config_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "delete" >/dev/null 2>&1
|
829
|
+
return $?
|
684
830
|
}
|
685
831
|
|
686
832
|
__rvm_trust_rvmrc() {
|
687
833
|
touch "$rvm_config_path/rvmrcs"
|
688
834
|
__rvm_reset_rvmrc_trust "$1"
|
689
835
|
"$rvm_scripts_path/db" "$rvm_config_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "1" >/dev/null 2>&1
|
836
|
+
return $?
|
690
837
|
}
|
691
838
|
|
692
839
|
__rvm_untrust_rvmrc() {
|
693
840
|
touch "$rvm_config_path/rvmrcs"
|
694
841
|
__rvm_reset_rvmrc_trust "$1"
|
695
842
|
"$rvm_scripts_path/db" "$rvm_config_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "0" >/dev/null 2>&1
|
843
|
+
return $?
|
696
844
|
}
|
697
845
|
|
698
846
|
__rvm_rvmrc_stored_trust() {
|
699
847
|
touch "$rvm_config_path/rvmrcs"
|
700
848
|
"$rvm_scripts_path/db" "$rvm_config_path/rvmrcs" "$(__rvm_rvmrc_key "$1")"
|
849
|
+
return $?
|
701
850
|
}
|
702
851
|
|
703
852
|
__rvm_rvmrc_tools() {
|
@@ -728,13 +877,14 @@ __rvm_rvmrc_tools() {
|
|
728
877
|
fi
|
729
878
|
;;
|
730
879
|
load)
|
731
|
-
rvm_rvmrc_cwd="" rvm_trust_rvmrcs=1
|
880
|
+
rvm_rvmrc_cwd="" rvm_trust_rvmrcs=1 __rvm_project_rvmrc "$(dirname "$rvmrc_path")"
|
732
881
|
;;
|
733
882
|
*)
|
734
883
|
echo "Usage: rvm rvmrc {trust,untrust,trusted,load,reset}"
|
735
884
|
return 1
|
736
885
|
;;
|
737
886
|
esac
|
887
|
+
return $?
|
738
888
|
}
|
739
889
|
|
740
890
|
__rvm_check_rvmrc_trustworthiness() {
|
@@ -746,13 +896,15 @@ __rvm_check_rvmrc_trustworthiness() {
|
|
746
896
|
else
|
747
897
|
[[ "$value" = "1" ]]
|
748
898
|
fi
|
899
|
+
return $?
|
749
900
|
}
|
750
901
|
|
751
902
|
__rvm_ask_to_trust() {
|
752
903
|
[[ -n "$rvm_promptless" ]] && return 2
|
753
904
|
printf "
|
754
905
|
============================================================
|
755
|
-
RVM has encountered a
|
906
|
+
RVM has encountered a not yet trusted .rvmrc file in the
|
907
|
+
current working directory which contains the following code:
|
756
908
|
============================================================
|
757
909
|
|
758
910
|
$(cat $1)
|
@@ -789,17 +941,24 @@ $(cat $1)
|
|
789
941
|
# Checks the rvmrc for the given directory. Note that if
|
790
942
|
# argument is passed, it will be used instead of pwd.
|
791
943
|
__rvm_project_rvmrc() {
|
944
|
+
declare -i rvm_project_rvmrc_default=${rvm_project_rvmrc_default:-0}
|
945
|
+
declare rvm_rvmrc_cwd="${rvm_rvmrc_cwd:-""}"
|
946
|
+
declare rvm_previous_environment="${rvm_previous_environment:-""}"
|
947
|
+
|
792
948
|
local cwd
|
949
|
+
|
793
950
|
# Get the first argument or the pwd.
|
794
951
|
cwd="${1:-"$PWD"}"
|
795
952
|
while : ; do
|
796
953
|
if [[ -z "$cwd" || "$HOME" = "$cwd" || "/" = "$cwd" ]] ; then
|
797
954
|
if [[ -n "$rvm_rvmrc_cwd" ]] ; then
|
798
|
-
if [[
|
955
|
+
if [[ $rvm_project_rvmrc_default -eq 1 ]]; then
|
799
956
|
__rvm_load_env_file "default"
|
800
957
|
elif [[ -n "$rvm_previous_environment" ]] ; then
|
801
958
|
__rvm_load_env_file "$rvm_previous_environment"
|
802
|
-
fi
|
959
|
+
fi
|
960
|
+
rvm_rvmrc_cwd=""
|
961
|
+
rvm_previous_environment=""
|
803
962
|
fi
|
804
963
|
break
|
805
964
|
else
|
@@ -822,6 +981,7 @@ __rvm_project_rvmrc() {
|
|
822
981
|
fi
|
823
982
|
fi
|
824
983
|
done
|
984
|
+
return $?
|
825
985
|
}
|
826
986
|
|
827
987
|
__rvm_record_install() {
|
@@ -834,17 +994,18 @@ __rvm_record_install() {
|
|
834
994
|
\grep -v "^$recorded_ruby_name " < "$rvm_install_record_file" > "$rvm_install_record_file.tmp"
|
835
995
|
echo "$rvm_install_command" >> "$rvm_install_record_file.tmp"
|
836
996
|
\rm -f "$rvm_install_record_file"
|
837
|
-
mv "$rvm_install_record_file.tmp" "$rvm_install_record_file"
|
997
|
+
\mv "$rvm_install_record_file.tmp" "$rvm_install_record_file"
|
838
998
|
}
|
839
999
|
|
840
1000
|
__rvm_remove_install_record() {
|
841
1001
|
local recorded_ruby_name="$($rvm_scripts_path/tools strings "$1")"
|
842
1002
|
local rvm_install_record_file="$rvm_config_path/installs"
|
843
1003
|
if [[ -s "$rvm_install_record_file" ]]; then
|
844
|
-
mv "$rvm_install_record_file" "$rvm_install_record_file.tmp"
|
1004
|
+
\mv "$rvm_install_record_file" "$rvm_install_record_file.tmp"
|
845
1005
|
\grep -v "^$recorded_ruby_name " < "$rvm_install_record_file.tmp" > "$rvm_install_record_file"
|
846
1006
|
\rm -f "$rvm_install_record_file.tmp"
|
847
1007
|
fi
|
1008
|
+
return 0
|
848
1009
|
}
|
849
1010
|
|
850
1011
|
__rvm_recorded_install_command() {
|
@@ -856,35 +1017,39 @@ __rvm_recorded_install_command() {
|
|
856
1017
|
else
|
857
1018
|
return 1
|
858
1019
|
fi
|
1020
|
+
return $?
|
859
1021
|
}
|
860
1022
|
|
861
1023
|
__rvm_environment_identifier() {
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
1024
|
+
local path
|
1025
|
+
local string
|
1026
|
+
path="$(command -v ruby)"
|
1027
|
+
string="${path//*rubies\//}"
|
1028
|
+
string="${string//\/*/}"
|
1029
|
+
echo "${string:-system}"
|
1030
|
+
return $?
|
869
1031
|
}
|
870
1032
|
|
871
1033
|
__rvm_expand_ruby_string() {
|
872
|
-
|
1034
|
+
local string="$1"
|
1035
|
+
if [[ -z "$string" || "$string" = "all" ]]; then
|
873
1036
|
"$rvm_scripts_path/list" strings | tr ' ' "\n" | __rvm_strip
|
874
|
-
elif [[ "$
|
1037
|
+
elif [[ "$string" = "all-gemsets" ]]; then
|
875
1038
|
"$rvm_scripts_path/list" gemsets strings | __rvm_strip
|
876
|
-
elif [[ "$
|
1039
|
+
elif [[ "$string" = "default-with-rvmrc" || "$string" = "rvmrc" ]]; then
|
877
1040
|
"$rvm_scripts_path/tools" path-identifier "$PWD"
|
878
|
-
elif [[ "$
|
1041
|
+
elif [[ "$string" == "all-rubies" || "$string" = "rubies" ]]; then
|
879
1042
|
"$rvm_scripts_path/list" rubies strings | __rvm_strip
|
880
|
-
elif [[ "$
|
881
|
-
local current_ruby="$(__rvm_environment_identifier | awk -F"$rvm_gemset_separator" '{print $
|
1043
|
+
elif [[ "$string" == "current-ruby" || "$string" = "gemsets" ]]; then
|
1044
|
+
local current_ruby="$(__rvm_environment_identifier | awk -F"$rvm_gemset_separator" '{print $string}')"
|
882
1045
|
rvm_silence_logging=1 "$rvm_scripts_path/gemsets" list | sed "s/^/$current_ruby$rvm_gemset_separator/" | __rvm_strip
|
883
|
-
elif [[ "$
|
1046
|
+
elif [[ "$string" = "current" ]]; then
|
884
1047
|
__rvm_environment_identifier
|
885
|
-
elif [[ "$
|
886
|
-
awk -F= '{print $
|
1048
|
+
elif [[ "$string" = "aliases" ]]; then
|
1049
|
+
awk -F= '{print $string}' < "$rvm_config_path/alias" | __rvm_strip
|
887
1050
|
else
|
888
|
-
echo "$
|
1051
|
+
echo "$string" | tr "," "\n" | __rvm_strip
|
889
1052
|
fi
|
1053
|
+
return $?
|
890
1054
|
}
|
1055
|
+
|