scripts/utility in rvm-0.1.45 vs scripts/utility in rvm-0.1.46

- old
+ new

@@ -44,14 +44,14 @@ __rvm_dump_environment() { local dump_environment_file="$(echo "$rvm_dump_environment_flag" | awk -F, '{print $1}')" local dump_environment_type="$(echo "$rvm_dump_environment_flag" | awk -F, '{print $2}')" if [[ -n "$dump_environment_file" && -n "$dump_environment_type" ]]; then if [[ "$dump_environment_type" == "atheis"* ]]; then - rm -rf "$dump_environment_file" && ln -s /dev/null "$dump_environment_file" >/dev/null 2>&1 + \rm -rf "$dump_environment_file" && ln -s /dev/null "$dump_environment_file" >/dev/null 2>&1 else $rvm_scripts_path/environment-convertor "$dump_environment_type" "$(__rvm_environment_identifier)" > "$dump_environment_file" - [[ "$?" -gt 0 ]] && rm -rf "$dump_environment_file" + [[ "$?" -gt 0 ]] && \rm -rf "$dump_environment_file" fi fi unset rvm_dump_environment_flag } @@ -171,12 +171,12 @@ if [[ -n "$message" ]] ; then $rvm_scripts_path/log "info" "$message" ; fi if [[ -n "$rvm_debug_flag" ]] ; then $rvm_scripts_path/log "debug" "Executing: $command" fi - mkdir -p "$(dirname "$rvm_ruby_log_path/$log_file_name.log")" - touch "$rvm_ruby_log_path/$log_file_name.log" "$rvm_ruby_log_path/$log_file_name.error.log" # for zsh :( + \mkdir -p "$(dirname "$rvm_ruby_log_path/$log_file_name.log")" + \touch "$rvm_ruby_log_path/$log_file_name.log" "$rvm_ruby_log_path/$log_file_name.error.log" # for zsh :( echo "[$(date +'%Y-%m-%d %H:%M:%S')] $command" | tee "$rvm_ruby_log_path/$log_file_name.log" >> "$rvm_ruby_log_path/$log_file_name.error.log" if [[ -z "$rvm_niceness" ]] || [[ "0" = "$rvm_niceness" ]] ; then eval "$command" >> "$rvm_ruby_log_path/$log_file_name.log" 2>> "$rvm_ruby_log_path/$log_file_name.error.log" else eval "nice -n $rvm_niceness $command" >> $rvm_ruby_log_path/$log_file_name.log 2>> $rvm_ruby_log_path/$log_file_name.error.log @@ -193,12 +193,12 @@ if [[ -n "$message" ]] ; then $rvm_scripts_path/log "info" "$message" ; fi if [[ -n "$rvm_debug_flag" ]] ; then $rvm_scripts_path/log "debug" "Executing: $command in environment "$env_name"" fi - mkdir -p "$(dirname "$rvm_ruby_log_path/$log_file_name.log")" - touch "$rvm_ruby_log_path/$log_file_name.log" "$rvm_ruby_log_path/$log_file_name.error.log" # for zsh :( + \mkdir -p "$(dirname "$rvm_ruby_log_path/$log_file_name.log")" + \touch "$rvm_ruby_log_path/$log_file_name.log" "$rvm_ruby_log_path/$log_file_name.error.log" # for zsh :( echo "[$(date +'%Y-%m-%d %H:%M:%S')] $command # under $env_name" | tee "$rvm_ruby_log_path/$log_file_name.log" >> "$rvm_ruby_log_path/$log_file_name.error.log" if [[ -z "$rvm_niceness" ]] || [[ "0" = "$rvm_niceness" ]] ; then eval "__rvm_with_env '$env_name' '$command'" >> "$rvm_ruby_log_path/$log_file_name.log" 2>> "$rvm_ruby_log_path/$log_file_name.error.log" else eval "nice -n $rvm_niceness __rvm_with_env '$env_name' '$command'" >> $rvm_ruby_log_path/$log_file_name.log 2>> $rvm_ruby_log_path/$log_file_name.error.log @@ -271,11 +271,11 @@ # Cleans up temp folders for a given prefix, # typically the current process id. __rvm_cleanup_temp_for() { [[ -z "$1" ]] && return 1 if [[ -d "$rvm_tmp_path/" ]]; then - rm -rf "$rvm_tmp_path/$1"* >/dev/null 2>&1 + \rm -rf "$rvm_tmp_path/$1"* >/dev/null 2>&1 fi exit } __rvm_cleanup_temp_on_exit() { @@ -358,28 +358,28 @@ # rvm will refresh the stored information the next time it is called after reset. __rvm_reset() { PATH="$(echo $PATH | \tr ':' '\n' | awk '$0 !~ /rvm/' | paste -sd : -)" PATH="$rvm_bin_path:$PATH" ; export PATH - for flag in default passenger editor ; do rm -f "$rvm_bin_path"/${flag}_* ; done + for flag in default passenger editor ; do \rm -f "$rvm_bin_path"/${flag}_* ; done unset flag for file in system default ; do - [[ -f "${rvm_path}/${file}" ]] && rm -f "$rvm_path/${file}" - [[ -f "${rvm_config_path}/${file}" ]] && rm -f "$rvm_config_path/${file}" - [[ -f "${rvm_environments_path}/${file}" ]] && rm -f "$rvm_environments_path/${file}" + [[ -f "${rvm_path}/${file}" ]] && \rm -f "$rvm_path/${file}" + [[ -f "${rvm_config_path}/${file}" ]] && \rm -f "$rvm_config_path/${file}" + [[ -f "${rvm_environments_path}/${file}" ]] && \rm -f "$rvm_environments_path/${file}" done; unset file # Go back to a clean state. __rvm_become "system" __rvm_unset_ruby_variables for system_config in system_ruby system_gem_path system_user_gem_path ; do $rvm_scripts_path/db "$rvm_config_path/user" "$system_config" "delete" done ; unset system_config variable - rm -f $rvm_bin_path/ruby $rvm_bin_path/gem $rvm_bin_path/rake $rvm_bin_path/irb $rvm_bin_path/default* + \rm -f $rvm_bin_path/ruby $rvm_bin_path/gem $rvm_bin_path/rake $rvm_bin_path/irb $rvm_bin_path/default* } # Implode removes the entire rvm installation under $rvm_path. __rvm_implode() { while : ; do @@ -389,11 +389,11 @@ if [[ "/" = "$rvm_path" ]] ; then $rvm_scripts_path/log "error" "remove '/' ?!... NO!" else if [[ -d "$rvm_path" ]] ; then $rvm_scripts_path/log "info" "Hai! Removing $rvm_path" - rm -rf $rvm_path/ + \rm -rf $rvm_path/ echo "$rvm_path has been removed." else $rvm_scripts_path/log "info" "It appears that $rvm_path is already non existant." fi fi @@ -421,15 +421,15 @@ rvm_ruby_require="" __rvm_clean_path if echo "$PATH" | grep -q 'rvm\/bin:' ; then - PATH="$rvm_bin_path:$PATH" + PATH="${rvm_bin_path}:$PATH" export PATH fi - mkdir -p "$rvm_src_path" "$rvm_bin_path" "$rvm_archives_path" "$rvm_gems_path" "$rvm_tmp_path" "$rvm_repo_path" + \mkdir -p "$rvm_src_path" "$rvm_bin_path" "$rvm_archives_path" "$rvm_gems_path" "$rvm_tmp_path" "$rvm_repo_path" } # Update rubygems or binscripts based on CLI selection. __rvm_update() { __rvm_pushpop $rvm_path @@ -446,11 +446,11 @@ } # Update rvm using rubygems # If --head was specified, update from git repository master branch. __rvm_update_rvm() { - mkdir -p "$rvm_src_path" + \mkdir -p "$rvm_src_path" __rvm_pushpop "$rvm_src_path" if [[ "$rvm_head_flag" == "1" ]] ; then if [[ -d "$rvm_src_path/rvm/.git" ]] ; then builtin cd "$rvm_src_path/rvm/" && git pull origin master && ./scripts/install @@ -479,11 +479,11 @@ __rvm_reset mv $rvm_path/archives ~/.archives if [[ "/" = "$rvm_path" ]] ; then $rvm_scripts_path/log "error" "remove '/' ?!... NO!" else - if [[ -d "$rvm_path" ]] ; then rm -rf "$rvm_path/" ; fi + if [[ -d "$rvm_path" ]] ; then \rm -rf "$rvm_path/" ; fi fi gem install rvm $rvm_gem_options __rvm_update_rvm source $rvm_path/scripts/rvm else @@ -492,11 +492,11 @@ } # Create the irbrc for the currently selected ruby installation. __rvm_irbrc() { if [[ -d "$rvm_ruby_home" ]] && [[ ! -s "$rvm_ruby_irbrc" ]] ; then - cp $rvm_scripts_path/irbrc $rvm_ruby_irbrc + \cp $rvm_scripts_path/irbrc $rvm_ruby_irbrc fi } # Push or Pop a directory based on zero or one directory argument provided. __rvm_pushpop() { @@ -591,18 +591,18 @@ 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' + \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}" + \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" eval value=\$${variable} if [[ -n "$value" ]] ; then @@ -618,11 +618,11 @@ # We need to generate wrappers for both the default gemset and the global gemset. for wrapper_identifier in "$environment_identifier" "${environment_identifier}@global" ; do rvm_creating_default_wrappers=1 directory_name="$rvm_wrappers_path/$wrapper_identifier" if [[ ! -L "$directory_name" && ! -d "$directory_name" ]]; then - mkdir -p "$directory_name" + \mkdir -p "$directory_name" $rvm_scripts_path/wrapper "$wrapper_identifier" &> /dev/null fi unset rvm_creating_default_wrappers directory_name done; unset wrapper_identifier fi @@ -663,16 +663,17 @@ # Get the first argument or the pwd. cwd="${1:-"$(pwd)"}" while : ; do if [[ -z "$cwd" ]] || [[ "$HOME" = "$cwd" ]] || [[ "/" = "$cwd" ]] ; then if [[ -n "$rvm_rvmrc_cwd" ]] ; then - if [[ -z "$rvm_previous_environment" ]] ; then - rvm default 1>/dev/null 2>&1 + if [[ -f "$rvm_environments_path/$rvm_previous_environment" ]] ; then + . "$rvm_environments_path/$rvm_previous_environment" else - rvm "$rvm_previous_environment" 1>/dev/null 2>&1 - fi - unset rvm_rvmrc_cwd rvm_previous_environment + if [[ -f "$rvm_environments_path/default" ]] ; then + . "$rvm_environments_path/default" + fi + fi ; unset rvm_rvmrc_cwd rvm_previous_environment fi break else if [[ -f "$cwd/.rvmrc" ]] ; then if [[ "$rvm_rvmrc_cwd" != "$cwd" ]] ; then @@ -693,25 +694,25 @@ __rvm_record_install() { [[ -z "$1" ]] && return local recorded_ruby_name="$($rvm_scripts_path/tools strings "$1")" local rvm_install_record_file="$rvm_config_path/installs" local rvm_install_command="$(echo "$recorded_ruby_name $rvm_install_arguments" | __rvm_strip)" - touch "$rvm_install_record_file" - rm -f "$rvm_install_record_file.tmp" + \touch "$rvm_install_record_file" + \rm -f "$rvm_install_record_file.tmp" cat "$rvm_install_record_file" | grep -v "^$recorded_ruby_name " > "$rvm_install_record_file.tmp" echo "$rvm_install_command" >> "$rvm_install_record_file.tmp" - rm -f "$rvm_install_record_file" + \rm -f "$rvm_install_record_file" mv "$rvm_install_record_file.tmp" "$rvm_install_record_file" } __rvm_remove_install_record() { local recorded_ruby_name="$($rvm_scripts_path/tools strings "$1")" local rvm_install_record_file="$rvm_config_path/installs" if [[ -s "$rvm_install_record_file" ]]; then mv "$rvm_install_record_file" "$rvm_install_record_file.tmp" cat "$rvm_install_record_file.tmp" | grep -v "^$recorded_ruby_name " > "$rvm_install_record_file" - rm -f "$rvm_install_record_file.tmp" + \rm -f "$rvm_install_record_file.tmp" fi } __rvm_recorded_install_command() { local recorded_ruby_name="$($rvm_scripts_path/tools strings "$1" | awk -F"$rvm_gemset_separator" '{print $1}')" @@ -734,17 +735,19 @@ unset ruby_string } __rvm_expand_ruby_string() { if [[ -z "$1" || "$1" = "all" || "$1" == "all-gemsets" ]]; then - $rvm_scripts_path/list gemsets strings + $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_scripts_path/list strings | tr ' ' "\n" | __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_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}' + cat "$rvm_config_path/alias" | awk -F= '{print $1}' | __rvm_strip else echo "$1" | tr "," "\n" | __rvm_strip fi }