rvm 0.1.38 → 0.1.39

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.
@@ -79,7 +79,13 @@ source_path="${source_path:-$cwd}"
79
79
  rvm_archives_path="${rvm_archives_path:-"$rvm_path/archives"}"
80
80
  rvm_src_path="${rvm_src_path:-"$rvm_path/src"}"
81
81
  rvm_log_path="${rvm_log_path:-"$rvm_path/log"}"
82
- rvm_bin_path="${rvm_bin_path:-"$rvm_path/bin"}"
82
+
83
+ if [[ "root" = "$(whoami)" ]] ; then
84
+ rvm_bin_path="${rvm_bin_path:-"/usr/local/bin"}"
85
+ else
86
+ rvm_bin_path="${rvm_bin_path:-"$rvm_path/bin"}"
87
+ fi
88
+
83
89
  rvm_gems_path="${rvm_gems_path:-"$rvm_path/gems"}"
84
90
  rvm_rubies_path="${rvm_rubies_path:-"$rvm_path/rubies"}"
85
91
  rvm_scripts_path="${rvm_scripts_path:-"$rvm_path/scripts"}"
@@ -8,50 +8,63 @@ if [[ ! -z "$rvm_trace_flag" ]] ; then set -x ; export rvm_trace_flag ; fi
8
8
 
9
9
  trap "if [[ -d $rvm_tmp_path/ ]] && [[ -s $rvm_tmp_path/$$ ]] ; then rm -f $rvm_tmp_path/$$ > /dev/null 2>&1 ; fi ; exit" 0 1 2 3 15
10
10
 
11
- action="$1" ; shift
12
- args="$*"
13
- if [[ -z "$action" ]] ; then
11
+ if [[ -z "$1" ]] ; then
14
12
  $rvm_scripts_path/log "error" "Action must be specified."
15
13
  exit 1
16
14
  fi
17
15
 
16
+ action="$1" ; shift
17
+ args="$*"
18
+
19
+ __rvm_attempt_single_exec() {
20
+ # Return if we have multiple rubies. or we're not running exec.
21
+ if [[ "$action" != "exec" ]] || $rvm_scripts_path/match "$rvm_ruby_strings" ' '; then
22
+ return 1
23
+ fi
24
+ eval "exec $args"
25
+ }
26
+
18
27
  # Perform an action using one of a selected ruby's specified binaries.
19
28
  __rvm_ruby_do() {
20
29
  # Return on invalid rubies.
21
30
  __rvm_become || return 1
22
-
23
- binary="$(echo $action | sed 's#do$##')"
24
- if [[ -x "$rvm_ruby_home/bin/$binary" ]] ; then
25
- binary="$rvm_ruby_home/bin/$binary"
26
- elif [[ -x "$rvm_ruby_global_gems_path/bin/$binary" ]] ; then
27
- binary="$rvm_ruby_global_gems_path/bin/$binary"
28
- elif [[ -x "$rvm_ruby_gem_home/bin/$binary" ]] ; then
29
- binary="$rvm_ruby_gem_home/bin/$binary"
30
- elif [[ "system" = "$rvm_ruby_string" ]] && [[ -x "$(command -v $binary)" ]] ; then
31
- binary="$(basename $(command -v $binary) 2>/dev/null)"
31
+ if [[ "$action" = "exec" ]]; then
32
+ # Exec is a special case.
33
+ rvm_command="$args"
32
34
  else
33
- $rvm_scripts_path/log "warn" "'$binary not found for $rvm_ruby_string' either does not exist or is not executable? :("
34
- __rvm_unset_ruby_variables
35
- return 1
36
- fi
35
+ binary="$(echo $action | sed 's#do$##')"
36
+ if [[ -x "$rvm_ruby_home/bin/$binary" ]] ; then
37
+ binary="$rvm_ruby_home/bin/$binary"
38
+ elif [[ -x "$rvm_ruby_global_gems_path/bin/$binary" ]] ; then
39
+ binary="$rvm_ruby_global_gems_path/bin/$binary"
40
+ elif [[ -x "$rvm_ruby_gem_home/bin/$binary" ]] ; then
41
+ binary="$rvm_ruby_gem_home/bin/$binary"
42
+ elif [[ "system" = "$rvm_ruby_string" ]] && [[ -x "$(command -v $binary)" ]] ; then
43
+ binary="$(basename $(command -v $binary) 2>/dev/null)"
44
+ else
45
+ $rvm_scripts_path/log "warn" "'$binary not found for $rvm_ruby_string' either does not exist or is not executable? :("
46
+ __rvm_unset_ruby_variables
47
+ return 1
48
+ fi
37
49
 
38
- if [[ ! -z "$rvm_ruby_mode" ]] ; then
39
- rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_mode}"
40
- rvm_ruby_mode="--$(echo "$rvm_ruby_mode" | sed 's/^m//')"
41
- fi
50
+ if [[ ! -z "$rvm_ruby_mode" ]] ; then
51
+ rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_mode}"
52
+ rvm_ruby_mode="--$(echo "$rvm_ruby_mode" | sed 's/^m//')"
53
+ fi
42
54
 
43
- load_path="$(dirname $(command -v $binary) 2>/dev/null):$rvm_ruby_load_path"
44
- # TODO: the else case below should be run if $args =~ /\.rb$/
45
- if [[ "ruby" = "$(basename $binary)" ]] && [[ "$rvm_benchmark_flag" -ne 1 ]] ; then
46
- if $rvm_scripts_path/match "$args" "\.rb$" ; then
47
- if [[ -z "$prefix" ]] ; then prefix="-S" ; fi
48
- if ! $rvm_scripts_path/match "$args" "$prefix" ; then
49
- args="$prefix $args"
55
+ load_path="$(dirname $(command -v $binary) 2>/dev/null):$rvm_ruby_load_path"
56
+ # TODO: the else case below should be run if $args =~ /\.rb$/
57
+ if [[ "ruby" = "$(basename $binary)" ]] && [[ "$rvm_benchmark_flag" -ne 1 ]] ; then
58
+ if $rvm_scripts_path/match "$args" "\.rb$" ; then
59
+ if [[ -z "$prefix" ]] ; then prefix="-S" ; fi
60
+ if ! $rvm_scripts_path/match "$args" "$prefix" ; then
61
+ args="$prefix $args"
62
+ fi
50
63
  fi
64
+ rvm_command="$binary $rvm_ruby_mode $rvm_ruby_require -I$load_path $args"
65
+ else
66
+ rvm_command="$binary $rvm_ruby_mode $args"
51
67
  fi
52
- rvm_command="$binary $rvm_ruby_mode $rvm_ruby_require -I$load_path $args"
53
- else
54
- rvm_command="$binary $rvm_ruby_mode $args"
55
68
  fi
56
69
 
57
70
  if [[ ! -z "$rvm_json_flag" ]] || [[ ! -z "$rvm_yaml_flag" ]] || [[ ! -z "$rvm_summary_flag" ]] ; then
@@ -147,7 +160,12 @@ __rvm_json() {
147
160
  rubies=() ; successes=() ; errors=() ; statuses=()
148
161
 
149
162
  rvm_ruby_strings="${rvm_ruby_strings:-"$($rvm_scripts_path/list strings)"}"
150
- for rvm_ruby_string in $(echo "$rvm_ruby_strings" | tr ',' ' ') ; do
163
+ rvm_ruby_strings="$(echo "$rvm_ruby_strings" | tr ',' ' ')"
164
+
165
+ # Check for a single ruby && exec if present.
166
+ __rvm_attempt_single_exec
167
+
168
+ for rvm_ruby_string in ${rvm_ruby_strings} ; do
151
169
  __rvm_ruby_do
152
170
  done
153
171
 
@@ -79,7 +79,13 @@ source_path="${source_path:-$cwd}"
79
79
  rvm_archives_path="${rvm_archives_path:-"$rvm_path/archives"}"
80
80
  rvm_src_path="${rvm_src_path:-"$rvm_path/src"}"
81
81
  rvm_log_path="${rvm_log_path:-"$rvm_path/log"}"
82
- rvm_bin_path="${rvm_bin_path:-"$rvm_path/bin"}"
82
+
83
+ if [[ "root" = "$(whoami)" ]] ; then
84
+ rvm_bin_path="${rvm_bin_path:-"/usr/local/bin"}"
85
+ else
86
+ rvm_bin_path="${rvm_bin_path:-"$rvm_path/bin"}"
87
+ fi
88
+
83
89
  rvm_gems_path="${rvm_gems_path:-"$rvm_path/gems"}"
84
90
  rvm_rubies_path="${rvm_rubies_path:-"$rvm_path/rubies"}"
85
91
  rvm_scripts_path="${rvm_scripts_path:-"$rvm_path/scripts"}"
@@ -51,6 +51,18 @@ __rvm_db() {
51
51
 
52
52
  is_a_function() { type $1 | head -n 1 | grep -q "function" ; }
53
53
 
54
+ __rvm_quote_args() {
55
+ local quoted_string=""
56
+ for quoted_argument in "$@"; do
57
+ if echo "$quoted_argument" | grep -q " "; then
58
+ quoted_string="$quoted_string '$(echo "$quoted_argument" | sed "s/'/\\\'/g")'"
59
+ else
60
+ quoted_string="$quoted_string $quoted_argument"
61
+ fi
62
+ done
63
+ echo "$quoted_string" | sed -e 's/^ *//g' -e 's/ *$//g'
64
+ }
65
+
54
66
  __rvm_strings() {
55
67
  unset results
56
68
  for rvm_ruby_string in $(echo $rvm_ruby_args) ; do
@@ -108,6 +120,28 @@ __rvm_run() {
108
120
  unset log_file command
109
121
  }
110
122
 
123
+ # Runs a command in a given env.
124
+ __rvm_run_with_env() {
125
+ log_file_name="$1" ; env_name="$2" ; command="$3" ; message="$4"
126
+ if [[ -z "$env_name" ]]; then env_name="$(__rvm_environment_identifier)"; fi
127
+ if [[ -z "$rvm_ruby_log_path" ]] ; then rvm_ruby_log_path="$rvm_log_path" ; fi
128
+ if [[ ! -z "$message" ]] ; then $rvm_scripts_path/log "info" "$message" ; fi
129
+ if [[ ! -z "$rvm_debug_flag" ]] ; then
130
+ $rvm_scripts_path/log "debug" "Executing: $command in environment "$env_name""
131
+ fi
132
+
133
+ mkdir -p "$(dirname "$rvm_ruby_log_path/$log_file_name.log")"
134
+ touch "$rvm_ruby_log_path/$log_file_name.log" "$rvm_ruby_log_path/$log_file_name.error.log" # for zsh :(
135
+ 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"
136
+ if [[ -z "$rvm_niceness" ]] || [[ "0" = "$rvm_niceness" ]] ; then
137
+ 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"
138
+ else
139
+ 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
140
+ fi
141
+ if [[ $? -gt 0 ]] ; then $rvm_scripts_path/log "error" "Error running '$command' under $env_name, please check $rvm_ruby_log_path/$log_file_name*.log" ; __rvm_pushpop ; return 1 ; fi
142
+ unset log_file command env_name
143
+ }
144
+
111
145
  # Unset both rvm variables as well as ruby-specific variables
112
146
  # Preserve gemset if 'rvm_sticky' is set (persist gemset unless clear is explicitely called).
113
147
  __rvm_cleanup_variables() {
@@ -123,6 +157,18 @@ __rvm_unset_ruby_variables() {
123
157
  unset rvm_ruby_interpreter rvm_ruby_version rvm_url rvm_ruby_repo_url rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_make rvm_ruby_make_install rvm_ruby_revision rvm_ruby_tag rvm_release_version rvm_major_version rvm_minor_version rvm_ruby_gem_home rvm_ruby_binary rvm_ruby_home rvm_ruby_log_path rvm_ruby_src_path rvm_ruby_irbrc rvm_ruby_selected_flag rvm_ruby_src_path rvm_ruby_repo_url rvm_major_version rvm_minor_version rvm_ruby_gem_home rvm_head_flag rvm_ruby_configure rvm_ruby_mode rvm_ruby_package_file rvm_ruby_package_name rvm_ruby_gem_path rvm_ruby_name rvm_ruby_alias rvm_ruby_strings rvm_ruby_repo_path
124
158
  }
125
159
 
160
+ # Usage: __rvm_with_env 'env-name' 'command'
161
+ __rvm_with_env() {
162
+ [[ -n "$rvm_trace_flag" ]] && rvm_env_args="--trace"
163
+ rvm_env_command="$(echo "$2" | sed "s/rvm /rvm $rvm_env_args /")"
164
+ # Subshells!
165
+ (
166
+ source $rvm_scripts_path/rvm
167
+ rvm $rvm_env_args use $1 && eval "$rvm_env_command"
168
+ )
169
+ unset rvm_env_args rvm_env_command
170
+ }
171
+
126
172
  __rvm_set_rvmrc() {
127
173
  if [[ "$HOME" != "$(pwd)" ]] ; then
128
174
  if [[ "$rvm_verbose_flag" -eq 1 ]] ; then flags="use " ; fi
@@ -166,7 +212,15 @@ __rvm_benchmark() {
166
212
  rvm_benchmark_flag=1
167
213
  rvm_action="ruby"
168
214
  if [[ ! -z "$rvm_debug_flag" ]] ; then printf "\n$rvm_tmp_path/$$.rb:\n$(cat $rvm_tmp_path/$$.rb)" ; fi
215
+ # Override ruby string stuff, pass through.
216
+ old_rvm_ruby_string=$rvm_ruby_string
217
+ unset rvm_ruby_string
218
+ export rvm_ruby_strings
169
219
  $rvm_scripts_path/set $rvm_action $rvm_ruby_args
220
+ result=$?
221
+ # Restore the state pre-sets.
222
+ [[ -n "$old_rvm_ruby_string" ]] && rvm_ruby_string=$old_rvm_ruby_string
223
+ unset old_rvm_ruby_string
170
224
  }
171
225
 
172
226
  # Loop over the currently installed rubies and refresh their binscripts.
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
+ default_flag="$rvm_default_flag"
3
4
  # Prevent it from recursing.
4
5
  unset rvm_default_flag rvm_wrapper_name
5
6
 
@@ -18,17 +19,24 @@ full_binary_name() {
18
19
  wrap() {
19
20
  mkdir -p "$(dirname "$file_name")"
20
21
  rm -f "$file_name"
21
- printf "#!/usr/bin/env sh\n" > "$file_name"
22
- printf "source \"${rvm_environments_path}/${environment_identifier}\"\n" >> "$file_name"
23
- printf "exec $binary_name \"\$@\"\n" >> "$file_name"
22
+
23
+ echo "#!/usr/bin/env sh" > "$file_name"
24
+ echo "if [ -s \"${rvm_environments_path}/${environment_identifier}\" ] ; then" >> "$file_name"
25
+ echo " . \"${rvm_environments_path}/${environment_identifier}\"" >> "$file_name"
26
+ echo " exec $binary_name \"\$@\"" >> "$file_name"
27
+ echo "else" >> $file_name
28
+ echo " echo \"ERROR: Missing RVM environment file: '${rvm_environments_path}/${environment_identifier}'\"" >> $file_name
29
+ echo " exit 1" >> $file_name
30
+ echo "fi" >> $file_name
24
31
 
25
32
  if [[ -f $file_name ]] ; then chmod +x $file_name ; fi
26
33
  }
27
34
 
28
35
  symlink_binary() {
29
36
  # Generate the default wrapper with the given binary name.
30
- [[ ! -f "$file_name" ]] && wrap_binary
37
+ wrap_binary # Note, now forcing this every time to force clean.
31
38
  # Then symlink it into place.
39
+ rm -f "${rvm_bin_path}/${prefix}_${binary_name}"
32
40
  ln -fs "$file_name" "${rvm_bin_path}/${prefix}_${binary_name}"
33
41
  }
34
42
 
@@ -48,6 +56,7 @@ usage() {
48
56
  }
49
57
 
50
58
  # Empty ruby string: show usage and exit.
59
+
51
60
  if [[ -z "$1" ]]; then
52
61
  usage
53
62
  exit 1
@@ -84,15 +93,20 @@ for binary_name in $binaries; do
84
93
  if [[ -z "$prefix" ]] ; then
85
94
  wrap_binary
86
95
  # Symlink it into place.
87
- if [[ "$binary_name" == "ruby" ]]; then
88
- ln -sf "$file_name" "$rvm_bin_path/$environment_identifier"
96
+ if [[ "$binary_name" == "ruby" ]] ; then
97
+ rm -f "${rvm_bin_path}/${environment_identifier}"
98
+ ln -nsf "${file_name}" "${rvm_bin_path}/${environment_identifier}"
89
99
  else
90
- ln -sf "$file_name" "$rvm_bin_path/$binary_name-$environment_identifier"
100
+ rm -f "${rvm_bin_path}/${binary_name}-${environment_identifier}"
101
+ ln -nsf "${file_name}" "${rvm_bin_path}/${binary_name}-${environment_identifier}"
102
+ fi
103
+ if [[ "root" = "$(whoami)" ]] && [[ "${default_flag}" = 1 ]] ; then
104
+ rm -f "${rvm_bin_path}/${binary_name}"
105
+ ln -nsf "${file_name}" "${rvm_bin_path}/${binary_name}"
91
106
  fi
92
107
  else
93
108
  symlink_binary
94
- fi
95
- unset file_name
109
+ fi ; unset file_name
96
110
  done
97
111
 
98
112
  exit $?
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rvm
3
3
  version: !ruby/object:Gem::Version
4
- hash: 87
4
+ hash: 85
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 38
10
- version: 0.1.38
9
+ - 39
10
+ version: 0.1.39
11
11
  platform: ruby
12
12
  authors:
13
13
  - Wayne E. Seguin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-03 00:00:00 -04:00
18
+ date: 2010-06-18 00:00:00 -04:00
19
19
  default_executable: rvm-install
20
20
  dependencies: []
21
21
 
@@ -105,6 +105,7 @@ files:
105
105
  - scripts/monitor
106
106
  - scripts/notes
107
107
  - scripts/package
108
+ - scripts/rubygems
108
109
  - scripts/rvm
109
110
  - scripts/rvm-install
110
111
  - scripts/selector