scripts/utility in rvm-0.1.38 vs scripts/utility in rvm-0.1.39
- old
+ new
@@ -49,10 +49,22 @@
unset key value variable
}
is_a_function() { type $1 | head -n 1 | grep -q "function" ; }
+__rvm_quote_args() {
+ local quoted_string=""
+ for quoted_argument in "$@"; do
+ if echo "$quoted_argument" | grep -q " "; then
+ quoted_string="$quoted_string '$(echo "$quoted_argument" | sed "s/'/\\\'/g")'"
+ else
+ quoted_string="$quoted_string $quoted_argument"
+ fi
+ done
+ echo "$quoted_string" | sed -e 's/^ *//g' -e 's/ *$//g'
+}
+
__rvm_strings() {
unset results
for rvm_ruby_string in $(echo $rvm_ruby_args) ; do
#__rvm_ruby_string
if [[ $? -gt 0 ]] ; then
@@ -106,10 +118,32 @@
fi
if [[ $? -gt 0 ]] ; then $rvm_scripts_path/log "error" "Error running '$command', please check $rvm_ruby_log_path/$log_file_name*.log" ; __rvm_pushpop ; return 1 ; fi
unset log_file command
}
+# Runs a command in a given env.
+__rvm_run_with_env() {
+ log_file_name="$1" ; env_name="$2" ; command="$3" ; message="$4"
+ if [[ -z "$env_name" ]]; then env_name="$(__rvm_environment_identifier)"; fi
+ if [[ -z "$rvm_ruby_log_path" ]] ; then rvm_ruby_log_path="$rvm_log_path" ; fi
+ if [[ ! -z "$message" ]] ; then $rvm_scripts_path/log "info" "$message" ; fi
+ if [[ ! -z "$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 :(
+ 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
+ fi
+ if [[ $? -gt 0 ]] ; then $rvm_scripts_path/log "error" "Error running '$command' under $env_name, please check $rvm_ruby_log_path/$log_file_name*.log" ; __rvm_pushpop ; return 1 ; fi
+ unset log_file command env_name
+}
+
# Unset both rvm variables as well as ruby-specific variables
# Preserve gemset if 'rvm_sticky' is set (persist gemset unless clear is explicitely called).
__rvm_cleanup_variables() {
__rvm_unset_ruby_variables
@@ -121,10 +155,22 @@
# Unset ruby-specific variables
__rvm_unset_ruby_variables() {
unset rvm_ruby_interpreter rvm_ruby_version rvm_url rvm_ruby_repo_url rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_make rvm_ruby_make_install rvm_ruby_revision rvm_ruby_tag rvm_release_version rvm_major_version rvm_minor_version rvm_ruby_gem_home rvm_ruby_binary rvm_ruby_home rvm_ruby_log_path rvm_ruby_src_path rvm_ruby_irbrc rvm_ruby_selected_flag rvm_ruby_src_path rvm_ruby_repo_url rvm_major_version rvm_minor_version rvm_ruby_gem_home rvm_head_flag rvm_ruby_configure rvm_ruby_mode rvm_ruby_package_file rvm_ruby_package_name rvm_ruby_gem_path rvm_ruby_name rvm_ruby_alias rvm_ruby_strings rvm_ruby_repo_path
}
+# Usage: __rvm_with_env 'env-name' 'command'
+__rvm_with_env() {
+ [[ -n "$rvm_trace_flag" ]] && rvm_env_args="--trace"
+ rvm_env_command="$(echo "$2" | sed "s/rvm /rvm $rvm_env_args /")"
+ # Subshells!
+ (
+ source $rvm_scripts_path/rvm
+ rvm $rvm_env_args use $1 && eval "$rvm_env_command"
+ )
+ unset rvm_env_args rvm_env_command
+}
+
__rvm_set_rvmrc() {
if [[ "$HOME" != "$(pwd)" ]] ; then
if [[ "$rvm_verbose_flag" -eq 1 ]] ; then flags="use " ; fi
if [[ -s .rvmrc ]] ; then
@@ -164,10 +210,18 @@
printf "\n end \nend\n" >> "$rvm_tmp_path/$$.rb"
rvm_ruby_args="$rvm_tmp_path/$$.rb"
rvm_benchmark_flag=1
rvm_action="ruby"
if [[ ! -z "$rvm_debug_flag" ]] ; then printf "\n$rvm_tmp_path/$$.rb:\n$(cat $rvm_tmp_path/$$.rb)" ; fi
+ # Override ruby string stuff, pass through.
+ old_rvm_ruby_string=$rvm_ruby_string
+ unset rvm_ruby_string
+ export rvm_ruby_strings
$rvm_scripts_path/set $rvm_action $rvm_ruby_args
+ result=$?
+ # Restore the state pre-sets.
+ [[ -n "$old_rvm_ruby_string" ]] && rvm_ruby_string=$old_rvm_ruby_string
+ unset old_rvm_ruby_string
}
# Loop over the currently installed rubies and refresh their binscripts.
__rvm_bin_scripts() {
for rvm_ruby_binary in $rvm_rubies_path/*/bin/ruby ; do