scripts/manage in rvm-1.0.2 vs scripts/manage in rvm-1.0.3
- old
+ new
@@ -1,7 +1,9 @@
#!/usr/bin/env bash
+if [[ "$rvm_trace_flag" -eq 2 ]] ; then set -x ; export rvm_trace_flag ; fi
+
original_ruby_version=$rvm_ruby_version
original_ruby_string=$rvm_ruby_string
source "$rvm_scripts_path/base"
source "$rvm_scripts_path/patches"
@@ -21,41 +23,52 @@
return 1
fi
fi
}
-# Returns a number of patches, each on a new name
+# Emits a number of patches to STDOUT, each on a new name
# Expands patchsets etc.
__rvm_current_patch_names() {
# TODO: Lookup default patches on rvm_ruby_string heirarchy.
- local patch_level_seperator="%"
+ local separator="%"
local patches="$rvm_patch_names default"
- for patch_name in $(printf "$patches" | sed -e "s/,/ /g" -e "s#$patch_level_seperator#\\$patch_level_seperator#g" | __rvm_strip); do
- __rvm_expand_patch_name "${patch_name//${patch_level_seperator}*/}"
+ for patch_name in $(echo "$patches" | \tr ',' ' ' | __rvm_strip); do
+ local level=1
+ local name="$patch_name"
+ if echo "$name" | \grep -q "$separator"; then
+ level="${name/*${separator}/}"
+ name="${name//${separator}*/}"
+ fi
+ local expanded_name="$(__rvm_expand_patch_name "$name")"
+ echo "${expanded_name}${separator}${level}"
done
}
__rvm_apply_patches() {
local patch_result=0
- local patch_level_seperator="%"
+ local patch_level_separator="%"
local patch_fuzziness="25"
+ local patch_level=1
source_directory="${1:-"$rvm_ruby_src_path"}"
__rvm_pushpop "$source_directory"
unset source_directory
- for patch_name in $(__rvm_current_patch_names | __rvm_strip); do
- patch_level="1"
+ patches="$(__rvm_current_patch_names | __rvm_strip)"
+ for patch_name in $(echo $patches); do
# If set, extract the patch level from the patch name.
- if echo "$patch_name" | \grep -q "$patch_level_seperator"; then
- patch_level="${patch_name/*${patch_level_seperator}/}"
- patch_name="${patch_name/${patch_level_seperator}*/}"
+ patch_level=1
+ if echo "$patch_name" | \grep -q "$patch_level_separator"; then
+ patch_level="${patch_name//*${patch_level_separator}/}"
+ patch_name="${patch_name//${patch_level_separator}*/}"
fi
full_patch_path="$(__rvm_lookup_full_patch_path "$patch_name")"
# Expand paths, and for those we found we then apply the patches.
if [[ -n "$full_patch_path" ]]; then
- __rvm_run "patch.apply.${patch_name/*\/}" "patch -F$patch_fuzziness -p$patch_level -f <\"$full_patch_path\"" "Applying patch '$patch_name' (located at $full_patch_path)"
- # Detect failed patches
- [[ "$?" -gt 0 ]] && patch_result=1
+ if [[ -f "$full_patch_path" ]] ; then
+ __rvm_run "patch.apply.${patch_name/*\/}" "patch -F$patch_fuzziness -p$patch_level -f <\"$full_patch_path\"" "Applying patch '$patch_name' (located at $full_patch_path)"
+ # Detect failed patches
+ [[ "$?" -gt 0 ]] && patch_result=1
+ fi
else
"$rvm_scripts_path/log" "warn" "Patch '$patch_name' not found."
patch_result=1
fi
done; unset patch_name full_patch_path patch_level
@@ -248,11 +261,11 @@
"$rvm_scripts_path/log" "fail" "MacRuby can only be installed on a Darwin OS."
fi
;;
ree)
- if [[ -n "$(echo "$rvm_ruby_version" | awk '/^1\.8/')" ]] && [[ -z "$rvm_head_flag" ]] ; then
+ if [[ -n "$(echo "$rvm_ruby_version" | awk '/^1\.8/')" ]] && [[ $rvm_head_flag -eq 0 ]] ; then
rvm_url="$(__rvm_db "ree_${rvm_ruby_version}_url")/$rvm_ruby_package_file.tar.gz"
"$rvm_scripts_path/log" "info" "Installing Ruby Enterprise Edition from source to: $rvm_ruby_home"
__rvm_pushpop "$rvm_src_path"
if [[ -z "$rvm_force_flag" ]] && [[ -d "$rvm_ruby_src_path" ]] && [[ ! -x "$rvm_ruby_src_path/installer" ]] ; then
"$rvm_scripts_path/log" "It appears that the archive has already been extracted. Skipping extract (use --force to force re-download and extract)."
@@ -326,11 +339,11 @@
unset BUNDLE_PATH GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC
__rvm_remove_rvm_from_path
__rvm_conditionally_add_bin_path ; export PATH
builtin hash -r
- if [[ -n "$(echo $rvm_ruby_version | awk '/^1\.0/')" ]] && [[ -z "$rvm_head_flag" ]] ; then
+ if [[ -n "$(echo $rvm_ruby_version | awk '/^1\.0/')" ]] && [[ $rvm_head_flag -eq 0 ]] ; then
"$rvm_scripts_path/log" "info" "Downloading $rvm_ruby_package_file, this may take a while depending on your connection..."
"$rvm_scripts_path/fetch" "$rvm_url"
result=$? ; if [[ "$result" -gt 0 ]] ; then
"$rvm_scripts_path/log" "error" "There has been an error while trying to fetch the source. Aborting the installation." ; __rvm_pushpop ; return $result
fi
@@ -420,11 +433,11 @@
result=$? ; if [[ "$result" -gt 0 ]] ; then
"$rvm_scripts_path/log" "error" "There has been an error while trying to fetch the source. Aborting the installation." ; __rvm_pushpop ; return $result
fi
builtin cd "$rvm_ruby_src_path"
- if [[ -n "$rvm_head_flag" ]] ; then __rvm_run "ant.dist" "ant dist" "Running 'ant dist' (this could take a few minutes) ..." ; fi
+ if [[ $rvm_head_flag -eq 1 ]] ; then __rvm_run "ant.dist" "ant dist" "Running 'ant dist' (this could take a few minutes) ..." ; fi
\mkdir -p "$rvm_ruby_home/bin/"
if "$rvm_scripts_path/match" "$rvm_ruby_version" "1\.3" || "$rvm_scripts_path/match" "$rvm_ruby_version" "1\.2" ; then
__rvm_run "nailgun" "builtin cd \"$rvm_ruby_src_path/tool/nailgun\" && make $rvm_make_flags" "Building Nailgun"
else
@@ -487,11 +500,11 @@
result=$? ; if [[ "$result" -gt 0 ]] ; then
"$rvm_scripts_path/log" "error" "There has been an error while trying to fetch the source. Aborting the installation." ; __rvm_pushpop ; return $result
fi
fi
- if [[ -n "$rvm_head_flag" ]] ; then
+ if [[ $rvm_head_flag -eq 1 ]] ; then
builtin cd "$rvm_ruby_src_path"
rvm_gemstone_package_file="GemStone-$(\grep ^GEMSTONE version.txt | cut -f2 -d-).$(uname -sm | \tr ' ' '-')"
rvm_gemstone_url="${rvm_gemstone_url:-"$maglev_url/${rvm_gemstone_package_file}.${rvm_archive_extension}"}"
fi
@@ -532,11 +545,11 @@
for binary in maglev-ruby maglev-irb maglev-gem ; do
__rvm_inject_gem_env "$rvm_ruby_home/bin/$binary"
done ; unset binary
builtin cd "$rvm_ruby_home"
- if [[ -n "$rvm_head_flag" ]] ; then
+ if [[ $rvm_head_flag -eq 1 ]] ; then
git submodule update --init
"$rvm_ruby_home/bin/maglev" force-reload
ln -sf maglev.demo.key-$(uname -sm | \tr ' ' '-') etc/maglev.demo.key
fi
@@ -567,11 +580,11 @@
ironruby|ir)
if ! command -v mono > /dev/null ; then
printf "mono must be installed and in your path in order to install IronRuby." ; return 1
fi
- if [[ "$rvm_head_flag" = 1 ]] ; then
+ if [[ $rvm_head_flag -eq 1 ]] ; then
mono_version="$(mono -V | head -n 1 | cut -d ' ' -f5)"
if "$rvm_scripts_path/match" "$mono_version" "([0-9]+)\.([0-9]+)\.?([0-9]+)?" ; then
mono_major_ver="$(echo "$mono_version" | cut -d '.' -f1)"
mono_minor_ver="$(echo "$mono_version" | cut -d '.' -f2)"
if [[ $mono_major_ver -lt 2 ]] || ( [[ $mono_major_ver -eq 2 ]] && [[ $mono_minor_ver -lt 6 ]] ) ; then
@@ -753,11 +766,11 @@
}
__rvm_fetch_ruby() {
[[ -z "$rvm_ruby_selected_flag" ]] && __rvm_select
- if [[ -z "$rvm_head_flag" && -z "$rvm_ruby_tag" && -z "$rvm_ruby_revision" ]] ; then
+ if [[ $rvm_head_flag -eq 0 && -z "$rvm_ruby_tag" && -z "$rvm_ruby_revision" ]] ; then
rvm_ruby_package_name="${rvm_ruby_package_name:-"$rvm_ruby_string"}"
rvm_ruby_package_file="${rvm_ruby_package_file:-"$rvm_ruby_package_name"}"
if [[ "ruby" = "$rvm_ruby_interpreter" ]]; then
rvm_archive_extension="${rvm_archive_extension:-tar.bz2}"
else
@@ -803,11 +816,11 @@
result=$? ; if [[ "$result" -gt 0 ]] ; then
"$rvm_scripts_path/log" "error" "There has been an error while trying to extract the source. Aborting the installation." ; __rvm_pushpop ; return $result
fi
fi
- mv "/tmp/rvm_src_$$/$(\cd /tmp/rvm_src_$$ ; \ls)" "$rvm_ruby_src_path" ; \rm -rf "/tmp/rvm_src_$$"
+ mv "/tmp/rvm_src_$$/$(builtin cd /tmp/rvm_src_$$ ; \ls)" "$rvm_ruby_src_path" ; \rm -rf "/tmp/rvm_src_$$"
if [[ -n "$rvm_ruby_name" ]] && [[ -d "$rvm_src_path/$(echo $rvm_ruby_string | sed -e 's/-n.*//')" ]] ; then
mv "$rvm_src_path/$(echo "$rvm_ruby_string" | sed -e 's/-n.*//')" "$rvm_ruby_src_path"
fi
@@ -852,14 +865,14 @@
fi
else
if [[ -n "$rvm_ruby_tag" ]] ; then
# TODO: Check if tag v is valid
rvm_url="${rvm_url:-"$rvm_ruby_repo_url/tags/$(echo "$rvm_ruby_tag" | sed 's/^t//')"}"
- elif [[ -z "$rvm_ruby_version" ]] && [[ -n "$rvm_head_flag" ]] ; then
+ elif [[ -z "$rvm_ruby_version" && $rvm_head_flag -eq 1 ]] ; then
rvm_url="${rvm_url:-"$rvm_ruby_repo_url/trunk"}"
elif [[ "$rvm_major_version" = "9" ]] ; then
- if [[ -z "$rvm_minor_version" ]] || [[ "$rvm_minor_version" = 3 ]] ; then
+ if [[ -z "$rvm_minor_version" || "$rvm_minor_version" = 3 ]] ; then
rvm_url="${rvm_url:-"$rvm_ruby_repo_url/trunk"}"
else
rvm_url="${rvm_url:-"$rvm_ruby_repo_url/branches/ruby_${rvm_release_version}_${rvm_major_version}_${rvm_minor_version}"}"
fi
elif [[ -z "$rvm_minor_version" ]] || [[ "$rvm_major_version.$rvm_minor_version" = "8.8" ]] ; then
@@ -1036,11 +1049,11 @@
fi
done ; unset binary binaries
fi
# Import the initial gemsets.
- __rvm_run_with_env "gemsets.initial" "$rvm_ruby_string" 'rvm gemset initial' "Importing initial gems..."
+ __rvm_run_with_env "gemsets.initial" "$rvm_ruby_string" "'$rvm_scripts_path/gemsets' initial" "Importing initial gems..."
__rvm_irbrc
__rvm_generate_default_docs
if [[ -n "$rvm_ruby_aliases" ]]; then
@@ -1208,46 +1221,49 @@
local manage_result=0
if [[ -n "$rubies_string" ]] ;then
for rvm_ruby_string in $(echo "$rubies_string" | \tr ',' ' ') ; do
current_manage_ruby_string="$rvm_ruby_string"
- eval "__rvm_${rvm_action}_ruby"
+ eval "__rvm_${action}_ruby"
result="$?"
if [[ "$result" -gt 0 && "$manage_result" = 0 ]]; then
manage_result="$result"
fi
- [[ "$result" = 0 && "$rvm_action" = "install" ]] && __rvm_record_install "$current_manage_ruby_string"
+ [[ "$result" = 0 && "$action" = "install" ]] && __rvm_record_install "$current_manage_ruby_string"
unset current_manage_ruby_string
__rvm_unset_ruby_variables
done
else # all
- if [[ "$rvm_action" != "install" && "$rvm_action" != "remove" && "$rvm_action" != "uninstall" ]] ; then
+ if [[ "$action" != "install" && "$action" != "remove" && "$action" != "uninstall" ]] ; then
while read -r bin_line
do # Keep this on second line damnit!
if [[ -x "$bin_line" ]] ; then
current_manage_ruby_string="$(dirname "$bin_line" | xargs dirname | xargs basename)"
rvm_ruby_string="$current_manage_ruby_string"
- eval "__rvm_${rvm_action}_ruby"
+ eval "__rvm_${action}_ruby"
result="$?"
if [[ "$result" -gt 0 && "$manage_result" = 0 ]]; then
manage_result="$result"
fi
# record as current_manage_string to prevent it being overridden.
- [[ "$result" = 0 && "$rvm_action" = "install" ]] && __rvm_record_install "$current_manage_ruby_string"
+ [[ "$result" = 0 && "$action" = "install" ]] && __rvm_record_install "$current_manage_ruby_string"
unset current_manage_ruby_string
__rvm_unset_ruby_variables
fi
done < <(\ls "$rvm_rubies_path"/*/bin/ruby 2> /dev/null)
else
- "$rvm_scripts_path/log" "warn" 'Really? '"$rvm_action"' all? See "rvm list known" and limit the selection to something more sane please :)'
+ "$rvm_scripts_path/log" "warn" 'Really? '"$action"' all? See "rvm list known" and limit the selection to something more sane please :)'
fi
fi
# TODO: This should return the exit status of the command that got called.
return $manage_result
-
}
-rvm_action="$1"
-rubies_string="$2"
+args=($*)
+action="${args[0]}"
+rubies_string="${args[1]}"
+args="$(echo ${args[@]:2}) " # Strip trailing / leading / extra spacing.
+
__rvm_manage_rubies
+
exit $?