scripts/gems in rvm-0.0.67 vs scripts/gems in rvm-0.0.68

- old
+ new

@@ -169,33 +169,35 @@ gem_postfix="$(echo $gem | sed "s#${gem_name/ /}##" | sed "s#-v[=]*[ ]*${gem_version/ /}##")" fi if [[ -f "$gem" ]] ; then gem_file_name="$gem" - cache_file="$gem" - elif match "$gem" ".gem$" ]] ; then + elif match "$gem" ".gem$" ; then gem_file_name="$gem" elif [[ -z "${gem_version/ /}" ]] ; then # no version gem_file_name="${gem_name/ /}*.gem" else # version gem_file_name="${gem_name/ /}-${gem_version/ /}.gem" fi - if [[ -z "$rvm_force_flag" ]] && [[ -f "${rvm_ruby_gem_home}/specifications/${gem_file_name}" ]] ; then + if [[ -z "$rvm_force_flag" ]] && [[ -f "${rvm_ruby_gem_home}/specifications/${gem_file_name}spec" ]] ; then unset gem __rvm_log "warn" "$(__color "yellow")$gem_name $gem_version$(__color "none") exists, skipping (--force to re-install)" else - set -x - if [[ -f "$rvm_gem_path/cache/${gem_file_name}" ]] ; then + if [[ -f "$gem" ]] ; then + cache_file="$gem" + elif [[ -f "$rvm_gem_path/cache/${gem_file_name}" ]] ; then cache_file="$rvm_gem_path/cache/${gem_file_name}" else - cache_file="${cache_file:-$(/bin/ls -t "${rvm_gem_path}/*/*/cache/${gem_file_name}*" 2> /dev/null | head -n1)}" - if [[ -f "$cache_file" ]] ; then - cp "$cache_file" "$rvm_gem_path/cache/$(basename "$cache_file")" + cache_file="${cache_file:-$(ls ${rvm_gem_path}/*/*/cache/${gem_file_name}* 2> /dev/null | sort | head -n1)}" + if [[ ! -z "$cache_file" ]] && [[ -f "$cache_file" ]] ; then + if [[ "$(dirname $cache_file)" != "$rvm_gem_path/cache/" ]] ; then + cp "$cache_file" "$rvm_gem_path/cache/" + cache_file="$rvm_gem_path/cache/$(basename $cache_file)" + fi fi fi - set +x if [[ -z "$cache_file" ]] ; then if [[ -f "$gem_file_name" ]] ; then gem="$gem_file_name" elif [[ -z "${gem_version/ /}" ]] ; then @@ -208,10 +210,10 @@ gem_string="$(echo "$gem_file_name" | sed 's#\.gem$##')" # TODO: Switch this to use match if [[ ! -z "$(echo "$rvm_ruby_gem_list" | awk "/${gem_name/ /} \(.*$gem_version/{print}")" ]] ; then if [[ ! -z "$rvm_force_flag" ]] ; then - gem="$rvm_temp_path/$gem_file_name" # install as a named local gem + gem="$rvm_gem_path/cache/$gem_file_name" # install as a named local gem fi else gem="$cache_file" fi fi