scripts/wrapper in rvm-1.0.9 vs scripts/wrapper in rvm-1.0.10
- old
+ new
@@ -1,8 +1,9 @@
#!/usr/bin/env bash
default_flag="$rvm_default_flag"
+rvm_bin_path="${rvm_bin_path:-"$rvm_path/bin"}"
# Prevent recursion
unset rvm_default_flag rvm_wrapper_name prefix
source "$rvm_path/scripts/base"
@@ -16,52 +17,61 @@
Binaries
ruby, gem, rake, irb, rdoc, ri, testrb
For more information, see 'rvm help wrapper'
+
"
}
-full_binary_name() {
- echo "$binary_name" | __rvm_strip
-}
-
wrap() {
+
if [[ -n "${file_name:-""}" ]] ;then
+
mkdir -p "$(dirname "$file_name")"
rm -f "$file_name"
+ if [[ "root" = "$USER" ]] ; then
+ path="${rvm_path:-"/usr/local/rvm"}"
+ else
+ path="\$HOME/.rvm"
+ fi
+
printf "#!/usr/bin/env bash
-if [[ -s \"$rvm_path/environments/${environment_identifier}\" ]] ; then
- \\. \"$rvm_path/environments/${environment_identifier}\"
+if [[ -s \"$path/environments/${environment_identifier}\" ]] ; then
+ \\. \"$path/environments/${environment_identifier}\"
exec $binary_name \"\$@\"
else
- echo \"ERROR: Missing RVM environment file: '$rvm_path/environments/${environment_identifier}'\"
+ echo \"ERROR: Missing RVM environment file: '$path/environments/${environment_identifier}'\"
exit 1
fi
" > "$file_name"
if [[ -f "$file_name" ]] ; then chmod +x "$file_name" ; fi
return 0
+
else
+
"$rvm_path/scripts/log" "error" "wrap() : file_name unset variable."
+
return 1
+
fi
}
symlink_binary() {
# Generate the default wrapper with the given binary name.
# We first check if we can wrap the binary and if we were able to,
# we then symlink it into place.
if wrap_binary && [[ -f "$file_name" ]]; then
- rm -f "${rvm_bin_path:-"$rvm_path/bin"}/${prefix}_${binary_name}"
+ rm -f "$rvm_bin_path/${prefix}_${binary_name}"
- ln -fs "$file_name" "${rvm_bin_path:-"$rvm_path/bin"}/${prefix}_${binary_name}"
+ ln -fs "$file_name" "$rvm_bin_path/${prefix}_${binary_name}"
fi
}
wrap_binary() {
@@ -112,10 +122,16 @@
# it to the existing wrapper if needed.
for binary_name in "${binaries[@]}"; do
file_name="$rvm_path/wrappers/${environment_identifier}/${binary_name}"
+ if [[ ${rvm_default_flag:-0} -gt 0 ]] ; then
+
+ prefix="default"
+
+ fi
+
if [[ -z "$prefix" ]] ; then
override_check=1
wrap_binary
@@ -123,42 +139,49 @@
# Symlink it into place.
if [[ -f "$file_name" ]]; then
if [[ "$binary_name" == "ruby" ]] ; then
- destination="${rvm_bin_path:-"$rvm_path/bin"}/$environment_identifier"
+ destination="$rvm_bin_path/$environment_identifier"
else
- destination="${rvm_bin_path:-"$rvm_path/bin"}/${binary_name}-${environment_identifier}"
+ destination="$rvm_bin_path/${binary_name}-${environment_identifier}"
fi
rm -rf "$destination"
ln -nsf "$file_name" "$destination"
fi; unset destination
+
elif [[ "$prefix" == "--no-prefix" ]]; then
override_check=1
wrap_binary
if [[ -f "$file_name" ]]; then
- destination="${rvm_bin_path:-"$rvm_path/bin"}/$binary_name"
+ destination="$rvm_bin_path/$binary_name"
if [[ -s "$destination" ]] ; then
+
rm -rf "$destination"
+
fi
ln -nsf "$file_name" "$destination"
- fi ; unset destination
+ fi
else
+
symlink_binary
+
fi
+
+
done
exit $?