rvm 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,22 +1,39 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  default_flag="$rvm_default_flag"
4
- # Prevent it from recursing.
4
+ # Prevent recursion
5
5
  unset rvm_default_flag rvm_wrapper_name
6
6
 
7
7
  source "$rvm_scripts_path/base"
8
8
 
9
+ usage() {
10
+ printf "
11
+ Usage:
12
+
13
+ rvm wrapper [ruby_string] [wrapper_prefix] [binary[ binary[ ...]]]
14
+
15
+ Binaries
16
+
17
+ ruby, gem, rake, irb, rdoc, ri, testrb
18
+
19
+ For more information, see 'rvm help wrapper'
20
+ "
21
+ }
22
+
9
23
  full_binary_name() {
10
24
  echo "$binary_name" | __rvm_strip
11
25
  }
12
26
 
13
27
  wrap() {
14
- mkdir -p "$(dirname "$file_name")"
15
- rm -f "$file_name"
28
+ if [[ -n "${file_name:-""}" ]] ;then
29
+ mkdir -p "$(dirname "$file_name")"
30
+
31
+ rm -f "$file_name"
16
32
 
17
- printf "#!/usr/bin/env sh\n
18
- if [ -s \"${rvm_environments_path}/${environment_identifier}\" ] ; then
19
- \\. \"${rvm_environments_path}/${environment_identifier}\"
33
+ printf "#!/usr/bin/env bash
34
+
35
+ if [[ -s \"$rvm_path/environments/${environment_identifier}\" ]] ; then
36
+ \\. \"$rvm_path/environments/${environment_identifier}\"
20
37
  exec $binary_name \"\$@\"
21
38
  else
22
39
  echo \"ERROR: Missing RVM environment file: '${rvm_environments_path}/${environment_identifier}'\"
@@ -24,7 +41,13 @@ else
24
41
  fi
25
42
  " > "$file_name"
26
43
 
27
- if [[ -f "$file_name" ]] ; then chmod +x "$file_name" ; fi
44
+ if [[ -f "$file_name" ]] ; then chmod +x "$file_name" ; fi
45
+
46
+ return 0
47
+ else
48
+ "$rvm_path/scripts/log" "error" "wrap() : file_name unset variable."
49
+ return 1
50
+ fi
28
51
  }
29
52
 
30
53
  symlink_binary() {
@@ -33,6 +56,7 @@ symlink_binary() {
33
56
  # we then symlink it into place.
34
57
  if wrap_binary && [[ -f "$file_name" ]]; then
35
58
  rm -f "${rvm_bin_path}/${prefix}_${binary_name}"
59
+
36
60
  ln -fs "$file_name" "${rvm_bin_path}/${prefix}_${binary_name}"
37
61
  fi
38
62
  }
@@ -47,24 +71,26 @@ wrap_binary() {
47
71
  fi
48
72
  }
49
73
 
50
- usage() {
51
- printf "Usage: 'rvm wrapper [ruby_string] [wrapper_prefix] [binary[ binary[ ...]]]'\n"
52
- printf " Where binary defaults to ruby, gem, rake, irb, rdoc, ri, testrb\n"
53
- printf " For more information, see 'rvm help wrapper'\n"
54
- }
55
-
56
74
  # Empty ruby string: show usage and exit.
57
- if [[ -z "$1" ]]; then usage ; exit 1 ; fi
75
+ if [[ "$#" -eq 0 ]] ; then
76
+ usage
77
+ exit 1
78
+ else
79
+ ruby_string="${1:-""}"
80
+ shift
81
+ fi
82
+
83
+ if [[ "$#" -gt 0 ]] ; then
84
+ prefix="${1:-""}"
85
+ shift
86
+ fi
58
87
 
59
- ruby_string="${1:-""}"; shift
88
+ binaries=($(echo "$@"))
60
89
  override_check=0
61
- prefix="${1:-""}"
62
- [[ "$#" -gt 0 ]] && shift
63
- binaries="$(echo "$@" | __rvm_strip)"
64
90
 
65
91
  # Default the list of binaries to those we use regularily.
66
- if [[ -z "$binaries" ]] ; then
67
- binaries="ruby gem irb ri rdoc rake erb testrb"
92
+ if [[ ${#binaries[@]} -eq 0 ]] ; then
93
+ binaries=(ruby gem irb ri rdoc rake erb testrb)
68
94
  fi
69
95
 
70
96
  # Use the correct ruby.
@@ -76,31 +102,46 @@ environment_identifier="$(__rvm_environment_identifier)"
76
102
 
77
103
  # For each binary, we want to generate the wrapper / symlink
78
104
  # it to the existing wrapper if needed.
79
- for binary_name in $binaries; do
105
+ for binary_name in "${binaries[@]}"; do
106
+
80
107
  file_name="${rvm_wrappers_path}/${environment_identifier}/${binary_name}"
81
108
 
82
109
  if [[ -z "$prefix" ]] ; then
110
+
83
111
  override_check=1
112
+
84
113
  wrap_binary
114
+
85
115
  # Symlink it into place.
86
116
  if [[ -f "$file_name" ]]; then
117
+
87
118
  if [[ "$binary_name" == "ruby" ]] ; then
88
119
  destination="$rvm_bin_path/$environment_identifier"
89
120
  else
90
121
  destination="$rvm_bin_path/${binary_name}-${environment_identifier}"
91
122
  fi
123
+
92
124
  rm -rf "$destination"
125
+
93
126
  ln -nsf "$file_name" "$destination"
94
127
  fi; unset destination
95
128
 
96
129
  elif [[ "$prefix" == "--no-prefix" ]]; then
130
+
97
131
  override_check=1
132
+
98
133
  wrap_binary
134
+
99
135
  if [[ -f "$file_name" ]]; then
136
+
100
137
  destination="$rvm_bin_path/$binary_name"
101
- rm -rf "$destination"
138
+
139
+ if [[ -s "$destination" ]] ; then
140
+ rm -rf "$destination"
141
+ fi
142
+
102
143
  ln -nsf "$file_name" "$destination"
103
- fi; unset destination
144
+ fi ; unset destination
104
145
 
105
146
  else
106
147
  symlink_binary
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: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 5
10
- version: 1.0.5
9
+ - 6
10
+ version: 1.0.6
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-09-07 00:00:00 -04:00
18
+ date: 2010-09-10 00:00:00 -04:00
19
19
  default_executable: rvm-install
20
20
  dependencies: []
21
21