scripts/utility in rvm-0.1.46 vs scripts/utility in rvm-0.1.47
- old
+ new
@@ -589,18 +589,10 @@
__rvm_ensure_has_environment_files() {
local environment_identifier="$(__rvm_environment_identifier)"
file_name="${rvm_environments_path}/$environment_identifier"
- # Ensure system is a blank file.
- if [[ "$environment_identifier" == "system" ]]; then
- \rm -f "$file_name" 2>&1 | grep -v 'rm: cannot remove .* Permission denied'
- \mkdir -p "$(dirname "$file_name")"
- \touch "$file_name" 2>&1 | grep -v 'touch: cannot touch .* Permission denied'
- return
- fi
-
if [[ ! -s "$file_name" ]] ; then
\mkdir -p "${rvm_environments_path}"
echo "export PATH=\"${rvm_ruby_gem_home}/bin:${rvm_ruby_global_gems_path}/bin:${rvm_ruby_home}/bin:${rvm_bin_path}:\$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
eval "export $variable"
@@ -654,34 +646,40 @@
printf "\nhowever I can help you build a more "
printf "\npowerful Ruby which can compute the "
printf "\nUltimate Question."
}
+__rvm_load_env_file() {
+ if [[ -f "$rvm_environments_path/$1" ]]; then
+ # Restore the path to it's state minus rvm
+ PATH="$(echo $PATH | \tr ':' '\n' | awk '$0 !~ /rvm/' | paste -sd : -)"
+ . "$rvm_environments_path/$1"
+ else
+ rvm use "$1" >/dev/null 2>&1
+ fi
+}
+
# Checks the rvmrc for the given directory. Note that if
# argument is passed, it will be used instead of pwd.
__rvm_project_rvmrc() {
local cwd
# Get the first argument or the pwd.
cwd="${1:-"$(pwd)"}"
while : ; do
- if [[ -z "$cwd" ]] || [[ "$HOME" = "$cwd" ]] || [[ "/" = "$cwd" ]] ; then
+ if [[ -z "$cwd" || "$HOME" = "$cwd" || "/" = "$cwd" ]] ; then
if [[ -n "$rvm_rvmrc_cwd" ]] ; then
- if [[ -f "$rvm_environments_path/$rvm_previous_environment" ]] ; then
- . "$rvm_environments_path/$rvm_previous_environment"
- else
- if [[ -f "$rvm_environments_path/default" ]] ; then
- . "$rvm_environments_path/default"
- fi
+ if [[ "$rvm_project_rvmrc_default" = "1" ]]; then
+ __rvm_load_env_file "default"
+ elif [[ -n "$rvm_previous_environment" ]] ; then
+ __rvm_load_env_file "$rvm_previous_environment"
fi ; unset rvm_rvmrc_cwd rvm_previous_environment
fi
break
else
if [[ -f "$cwd/.rvmrc" ]] ; then
if [[ "$rvm_rvmrc_cwd" != "$cwd" ]] ; then
- if [[ -z "$rvm_previous_environment" ]] ; then
- rvm_previous_environment="$(__rvm_environment_identifier)"
- fi
+ rvm_previous_environment="$(__rvm_environment_identifier)"
rvm_rvmrc_cwd="$cwd"
source "$cwd/.rvmrc"
fi
break
else
@@ -734,15 +732,17 @@
fi
unset ruby_string
}
__rvm_expand_ruby_string() {
- if [[ -z "$1" || "$1" = "all" || "$1" == "all-gemsets" ]]; then
+ if [[ -z "$1" || "$1" = "all" ]]; then
+ $rvm_scripts_path/list strings | tr ' ' "\n" | __rvm_strip
+ elif [[ "$1" = "all" || "$1" == "all-gemsets" ]]; then
$rvm_scripts_path/list gemsets strings | __rvm_strip
elif [[ "$1" == "default-with-rvmrc" || "$1" == "rvmrc" ]]; then
$rvm_scripts_path/tools path-identifier "$(pwd)"
elif [[ "$1" == "all-rubies" || "$1" == "rubies" ]]; then
- $rvm_scripts_path/list strings | tr ' ' "\n" | __rvm_strip
+ $rvm_scripts_path/list rubies strings | __rvm_strip
elif [[ "$1" == "current" || "$1" == "gemsets" ]]; then
local current_ruby="$(__rvm_environment_identifier | awk -F"$rvm_gemset_separator" '{print $1}')"
rvm_silence_logging=1 $rvm_scripts_path/gemsets list | sed "s/^/$current_ruby$rvm_gemset_separator/" | __rvm_strip
elif [[ "$1" == "aliases" ]]; then
cat "$rvm_config_path/alias" | awk -F= '{print $1}' | __rvm_strip