scripts/utility in rvm-1.0.9 vs scripts/utility in rvm-1.0.10
- old
+ new
@@ -12,18 +12,21 @@
__shell_array_start=0 # bash array indexes are 0 based.
fi ; export __shell_array_start
}
__rvm_teardown() {
+
if [[ -n "${ZSH_VERSION:-""}" ]] ; then
- if [[ "$rvm_zsh_clobber" -eq 0 ]] ; then
+ if [[ ${rvm_zsh_clobber:-0} -eq 0 ]] ; then
setopt noclobber
- fi ; unset rvm_zsh_clobber
+ fi
+ unset rvm_zsh_clobber
+
else
: # currently we are not doing any option setting for bash.
fi
# Ruby strings are scoped to their action.
# Hence, we ensure we remove them at in
@@ -42,13 +45,12 @@
fi
fi
- unset rvm_ruby_strings rvm_head_flag rvm_prior_cc next_token rvm_bin_path rvm_error_message rvm_gems_cache_path rvm_gems_path rvm_gemset_name rvm_interactive_flag rvm_man_path rvm_parse_break rvm_rc_files rvm_ruby_binary rvm_ruby_gem_home rvm_ruby_gem_path rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_log_path rvm_ruby_major_version rvm_ruby_minor_version rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_revision rvm_ruby_selected_flag rvm_ruby_string rvm_ruby_tag rvm_ruby_version rvm_selfcontained rvm_token
+ unset rvm_ruby_strings rvm_head_flag rvm_prior_cc next_token rvm_bin_path rvm_error_message rvm_gems_cache_path rvm_gems_path rvm_gemset_name rvm_interactive_flag rvm_man_path rvm_parse_break rvm_rc_files rvm_ruby_binary rvm_ruby_gem_home rvm_ruby_gem_path rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_log_path rvm_ruby_major_version rvm_ruby_minor_version rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_revision rvm_ruby_selected_flag rvm_ruby_tag rvm_ruby_version rvm_selfcontained rvm_token rvm_ruby_load_path rvm_path_flag rvm_ruby_require rvm_project_rvmrc_default rvm_action
-
[[ ${rvm_dump_environment_flag:-0} -eq 1 ]] && __rvm_dump_environment
return 0
}
@@ -246,12 +248,12 @@
path="${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string"
log="$path/$name.log"
- if [[ ! -d "$path" ]] ; then
- \mkdir -p "$path"
+ if [[ ! -d "${log%\/*}" ]] ; then
+ \mkdir -p "${log%\/*}"
fi
\touch "$log" "${log/%.log/.error.log}" # for zsh :(
printf "[$(date +'%Y-%m-%d %H:%M:%S')] $command" | \
@@ -403,22 +405,26 @@
}
# Cleans up temp folders for a given prefix ($1),
# typically the current process id.
__rvm_cleanup_temp_for() {
+
result=$? # Capture last command status
[[ -z "${1:-""}" ]] && return 1
if [[ -d "${rvm_tmp_path:-"$rvm_path/tmp"}/" ]]; then
+
\rm -rf "${rvm_tmp_path:-"$rvm_path/tmp"}/$1"* >/dev/null 2>&1
+
fi
return $result
}
__rvm_set_rvmrc() {
+
local flags
if [[ "$HOME" != "$PWD" ]] ; then
if [[ ${rvm_verbose_flag:-0} -gt 0 ]] ; then
@@ -434,11 +440,17 @@
fi
local identifier=$(__rvm_environment_identifier)
- printf "if [[ -n \"\$rvm_path/environments\" && -s \"\$rvm_path/environments/$identifier\" ]] ; then\n \\. \"\$rvm_path/environments/$identifier\"\nelse\n rvm --create $flags \"$identifier\"\nfi" >> .rvmrc
+ printf "
+if [[ -d \"\$rvm_path/environments\" && -s \"\$rvm_path/environments/$identifier\" ]] ; then
+ \\. \"\$rvm_path/environments/$identifier\"
+else
+ rvm --create $flags \"$identifier\"
+fi
+" >> .rvmrc
else
"$rvm_path/scripts/log" "error" \
".rvmrc cannot be set in your home directory. \n The home .rvmrc is for global rvm settings only."
fi
@@ -548,14 +560,21 @@
# Add bin path if not present
__rvm_conditionally_add_bin_path() {
if echo "${PATH//:/ }" | \grep -vqF "${rvm_bin_path:-"$rvm_path/bin"} " ; then
- PATH="${rvm_bin_path:-"$rvm_path/bin"}:$PATH"
+ if [[ "${rvm_ruby_string:-"system"}" != "system" ]] ; then
- builtin hash -r
+ PATH="${rvm_bin_path:-"$rvm_path/bin"}:$PATH"
+ else
+
+ PATH="$PATH:${rvm_bin_path:-"$rvm_path/bin"}"
+
+ fi
+
+ builtin hash -r
fi
return 0
}
@@ -904,23 +923,23 @@
return 0
}
__rvm_ensure_has_environment_files() {
- local environment_identifier file_name directory_name wrapper_identifier variable value
+ local environment_id file_name directory_name wrapper_identifier variable value
- environment_identifier="$(__rvm_environment_identifier)"
+ environment_id="$(__rvm_environment_identifier)"
- file_name="${rvm_path}/environments/$environment_identifier"
+ file_name="${rvm_path}/environments/$environment_id"
if [[ ! -s "$file_name" ]] ; then
\mkdir -p "$rvm_path/environments"
echo "export PATH=\"${rvm_ruby_gem_home}/bin:${rvm_ruby_global_gems_path}/bin:${rvm_ruby_home}/bin:${rvm_bin_path:-"$rvm_path/bin"}:\$PATH\"" > "$file_name"
- for variable in RUBY_VERSION GEM_HOME GEM_PATH BUNDLE_PATH MY_RUBY_HOME IRBRC rvm_ruby_string rvm_gemset_name MAGLEV_HOME ; do
+ for variable in rvm_path RUBY_VERSION GEM_HOME GEM_PATH BUNDLE_PATH MY_RUBY_HOME IRBRC rvm_ruby_string rvm_gemset_name MAGLEV_HOME ; do
eval "export $variable"
eval "value=\${${variable}:-""}"
if [[ -n "$value" ]] ; then
@@ -931,26 +950,28 @@
done
fi
# Next, ensure we have default wrapper files. Also, prevent it from recursing.
- if [[ ${rvm_creating_default_wrappers:-0} -eq 1 ]]; then
+ if [[ ${rvm_create_default_wrappers:-0} -eq 1 || ! -f "$rvm_path/wrappers/$environment_id/ruby" ]] ; then
# We need to generate wrappers for both the default gemset and the global gemset.
- for wrapper_identifier in "$environment_identifier" "${environment_identifier}@global" ; do
+ for wrapper_identifier in "$environment_id" "${environment_id//@*/}@global" ; do
- rvm_creating_default_wrappers=1
+ rvm_create_default_wrappers=1
directory_name="$rvm_path/wrappers/$wrapper_identifier"
if [[ ! -L "$directory_name" && ! -d "$directory_name" ]]; then
\mkdir -p "$directory_name"
"$rvm_path/scripts/wrapper" "$wrapper_identifier" &> /dev/null
fi
- rvm_creating_default_wrappers=0
+
done
+
+ rvm_create_default_wrappers=0
fi
return 0
}
@@ -1288,43 +1309,72 @@
path="${GEM_HOME:-""}"
string="${path//*gems\//}"
string="${string//\/*/}"
- echo "${string:-system}"
+ printf "${string:-system}"
return $?
}
__rvm_expand_ruby_string() {
- local string="$1"
+ local string current_ruby
- if [[ -z "$string" || "$string" = "all" ]]; then
+ string="$1"
+
+ if [[ -z "$string" ]] ; then
+
"$rvm_path/scripts/list" strings | tr ' ' "\n"
- elif [[ "$string" = "all-gemsets" ]]; then
- "$rvm_path/scripts/list" gemsets strings
+ return $?
- elif [[ "$string" = "default-with-rvmrc" || "$string" = "rvmrc" ]]; then
- "$rvm_path/scripts/tools" path-identifier "$PWD"
+ fi
- elif [[ "$string" == "all-rubies" || "$string" = "rubies" ]]; then
- "$rvm_path/scripts/list" rubies strings
+ case "$string" in
- elif [[ "$string" == "current-ruby" || "$string" = "gemsets" ]]; then
- local current_ruby="$(__rvm_environment_identifier | awk -F"${rvm_gemset_separator:-"@"}" '{print $string}')"
- rvm_silence_logging=1 "$rvm_path/scripts/gemsets" list | sed "s/^/$current_ruby${rvm_gemset_separator:-"@"}/"
+ all)
+ "$rvm_path/scripts/list" strings | tr ' ' "\n"
+ ;;
- elif [[ "$string" = "current" ]]; then
- __rvm_environment_identifier
+ all-gemsets)
+ "$rvm_path/scripts/list" gemsets strings
+ ;;
- elif [[ "$string" = "aliases" ]]; then
- awk -F= '{print $string}' < "$rvm_path/config/alias"
+ default-with-rvmrc|rvmrc)
+ "$rvm_path/scripts/tools" path-identifier "$PWD"
+ ;;
- else
+ all-rubies|rubies)
+ "$rvm_path/scripts/list" rubies strings
+ ;;
- echo "$string" | tr "," "\n" | __rvm_strip
- fi
+ current-ruby|gemsets)
+ current_ruby="$(__rvm_environment_identifier | awk -F"${rvm_gemset_separator:-"@"}" '{print $string}')"
+
+ rvm_silence_logging=1 "$rvm_path/scripts/gemsets" list | sed "s/^/$current_ruby${rvm_gemset_separator:-"@"}/"
+ ;;
+
+ current)
+ __rvm_environment_identifier
+ ;;
+
+ aliases)
+ awk -F= '{print $string}' < "$rvm_path/config/alias"
+ ;;
+
+ *)
+ echo "$string" | tr "," "\n" | __rvm_strip
+ ;;
+
+ esac
+
return $?
}
+__rvm_regenerate_wrappers() {
+ echo "Regenerating all wrappers..."
+ while read -r wrapper_ruby_name; do
+ __rvm_run "wrappers.regenerate" "\"$rvm_path/scripts/wrapper\" '$wrapper_ruby_name'"
+ done < <(rvm list gemsets strings)
+ unset wrapper_ruby_name
+}
\ No newline at end of file