scripts/utility in rvm-1.0.7 vs scripts/utility in rvm-1.0.8
- old
+ new
@@ -13,31 +13,42 @@
fi ; export __shell_array_start
}
__rvm_teardown() {
if [[ -n "${ZSH_VERSION:-""}" ]] ; then
+
if [[ "$rvm_zsh_clobber" -eq 0 ]] ; then
+
setopt noclobber
+
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
# the cleanup phase.
# Clean up after CC switch
if [[ ${rvm_clang_flag:-0} -gt 0 ]] ; then
+
if [[ -n "${rvm_prior_cc:-""}" ]] ; then
+
export CC="$rvm_prior_cc"
+
else
+
unset CC
+
fi
+
fi
- unset rvm_ruby_strings rvm_head_flag rvm_prior_cc
+ unset rvm_ruby_strings rvm_head_flag rvm_prior_cc next_token result 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
+
[[ ${rvm_dump_environment_flag:-0} -eq 1 ]] && __rvm_dump_environment
return 0
}
@@ -89,23 +100,23 @@
return 0
}
# Query the rvm key-value database for a specific key
-# Allow overrides from user specifications in $rvm_config_path/user
+# Allow overrides from user specifications in $rvm_path/config/user
__rvm_db() {
local value key variable
key=${1:-""}
variable=${2:-""}
- if [[ -f "$rvm_config_path/user" ]] ; then
- value="$($rvm_path/scripts/db "$rvm_config_path/user" "$key")"
+ if [[ -f "$rvm_path/config/user" ]] ; then
+ value="$($rvm_path/scripts/db "$rvm_path/config/user" "$key")"
fi
if [[ -z "$value" ]] ; then
- value="$($rvm_path/scripts/db "$rvm_config_path/db" "$key")"
+ value="$($rvm_path/scripts/db "$rvm_path/config/db" "$key")"
fi
if [[ -n "$value" ]] ; then
if [[ -z "$variable" ]] ; then
echo $value
@@ -204,95 +215,106 @@
builtin hash -r
}
# Clean all rvm items out of the current working path.
__rvm_remove_rvm_from_path() {
- PATH="${PATH//${rvm_path}*rvm\/bin:}"
+ PATH="$(echo ${PATH} | awk -v RS=: -v ORS=: "/${rvm_path//\//\/}/ {next} {print}")"
export PATH
builtin hash -r
}
# Run a specified command and log it.
__rvm_run() {
- local log_file_name command message
+ local result log_file_name command message
log_file_name="${1:-""}"
command="${2:-""}"
message="${3:-""}"
- if [[ -z "${rvm_ruby_log_path:-""}" ]] ; then rvm_ruby_log_path="$rvm_log_path" ; fi
-
if [[ -n "$message" ]] ; then "$rvm_path/scripts/log" "info" "$message" ; fi
if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
"$rvm_path/scripts/log" "debug" "Executing: $command"
fi
- \mkdir -p "$(dirname "$rvm_ruby_log_path/$log_file_name.log")"
+ \mkdir -p "$(dirname "${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$log_file_name.log")"
- \touch "$rvm_ruby_log_path/$log_file_name.log" "$rvm_ruby_log_path/$log_file_name.error.log" # for zsh :(
+ \touch "${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$log_file_name.log" \
+ "${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$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"
+ echo "[$(date +'%Y-%m-%d %H:%M:%S')] $command" | \
+ \tee "${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$log_file_name.log" >> \
+ "${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$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"
+ eval "$command" >> \
+ "${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$log_file_name.log" 2>> \
+ "${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$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
+ eval "nice -n $rvm_niceness $command" >> \
+ ${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$log_file_name.log 2>> \
+ ${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$log_file_name.error.log
fi
)
local result=$?
if [[ $result -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
- "Error running '$command', please check $rvm_ruby_log_path/$log_file_name*.log"
+ "Error running '$command', please check ${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$log_file_name*.log"
fi
return $result
}
# Runs a command in a given env.
__rvm_run_with_env() {
- local log_file_name env_name comand message
+ local result log_file_name env_name comand message
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 [[ -n "$message" ]] ; then "$rvm_path/scripts/log" "info" "$message" ; fi
if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
"$rvm_path/scripts/log" "debug" "Executing: $command in environment "$env_name""
fi
- \mkdir -p "$(dirname "$rvm_ruby_log_path/$log_file_name.log")"
+ \mkdir -p "$(dirname "${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$log_file_name.log")"
- \touch "$rvm_ruby_log_path/$log_file_name.log" "$rvm_ruby_log_path/$log_file_name.error.log" # for zsh :(
+ \touch \
+ "${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$log_file_name.log" \
+ "${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$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"
+ echo "[$(date +'%Y-%m-%d %H:%M:%S')] $command # under $env_name" | \
+ tee "${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$log_file_name.log" >> \
+ "${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$log_file_name.error.log"
(
if [[ -z "${rvm_niceness:-""}" || $rvm_niceness -eq 0 ]] ; 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"
+ eval "__rvm_with_env '$env_name' '$command'" >> \
+ "${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$log_file_name.log" 2>> \
+ "${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$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
+ eval "nice -n $rvm_niceness __rvm_with_env '$env_name' '$command'" >> \
+ ${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$log_file_name.log 2>> \
+ ${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$log_file_name.error.log
fi
)
result=$?
if [[ $result -gt 0 ]] ; then
"$rvm_path/scripts/log" "error" \
- "Error running '$command' under $env_name, please check $rvm_ruby_log_path/$log_file_name*.log"
+ "Error running '$command' under $env_name, please check ${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/$log_file_name*.log"
fi
return $result
}
@@ -323,25 +345,26 @@
environment_id="$1"
command="$2"
(
- rvm use "$environment_id"
- eval "$command"
+ rvm use "$environment_id"
+
+ eval "$command"
)
}
# Returns the first 1.8.7-compatible (partly) ruby for use
# with things like rbx etc which require a ruby be installed.
__rvm_18_compat_ruby() {
local rubies ruby_name
- rubies=($( cd "$rvm_rubies_path" ; find . -maxdepth 1 -mindepth 1 -type d ))
+ rubies=($( cd "$rvm_path/rubies" ; find . -maxdepth 1 -mindepth 1 -type d ))
for ruby_name in "${rubies[@]//.\/}"; do
- if [[ ! -L "$rvm_rubies_path/$ruby_name" ]] ; then
+ if [[ ! -L "$rvm_path/rubies/$ruby_name" ]] ; then
case $ruby_name in
*1.8.*|rbx-*|ree-*) rubies="$rubies $ruby_name" ;;
esac
fi
@@ -373,186 +396,288 @@
fi
return 0
}
-# Cleans up temp folders for a given prefix,
+# Cleans up temp folders for a given prefix ($1),
# typically the current process id.
__rvm_cleanup_temp_for() {
result=$? # Capture last command status
- local prefix
+ [[ -z "${1:-""}" ]] && return 1
- prefix="$1"
-
- [[ -z "$prefix" ]] && return 1
-
- if [[ -d "$rvm_tmp_path/" ]]; then
- \rm -rf "$rvm_tmp_path/$prefix"* >/dev/null 2>&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 flags="use " ; fi
+ if [[ ${rvm_verbose_flag:-0} -gt 0 ]] ; then
+ flags="use "
+ fi
if [[ -s .rvmrc ]] ; then
+
mv .rvmrc .rvmrc.$(date +%m.%d.%Y-%H:%M:%S)
- "$rvm_path/scripts/log" "warning" ".rvmrc is not empty, moving aside to preserve."
+
+ "$rvm_path/scripts/log" "warning" \
+ ".rvmrc is not empty, moving aside to preserve."
+
fi
local identifier=$(__rvm_environment_identifier)
- printf "if [[ -n \"\$rvm_environments_path\" && -s \"\$rvm_environments_path/$identifier\" ]] ; then\n \\. \"\$rvm_environments_path/$identifier\"" > .rvmrc
- printf "\nelse\n rvm --create $flags \"$identifier\"\nfi" >> .rvmrc
+ 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
- unset flags
else
- "$rvm_path/scripts/log" "error" ".rvmrc cannot be set in your home directory. \n The home .rvmrc is for global rvm settings only."
+ "$rvm_path/scripts/log" "error" \
+ ".rvmrc cannot be set in your home directory. \n The home .rvmrc is for global rvm settings only."
fi
}
__rvm_load_rvmrc() {
- rvm_ignore_rvmrc=${rvm_ignore_rvmrc:-0}
- [[ $rvm_ignore_rvmrc -eq 1 ]] && return 0
+ [[ ${rvm_ignore_rvmrc:-0} -eq 1 ]] && return 0
+
for rvmrc in /etc/rvmrc $HOME/.rvmrc ; do
+
if [[ -f "$rvmrc" ]] ; then
+
if \grep -q '^\s*rvm .*$' $rvmrc ; then
- "$rvm_path/scripts/log" "error" "$rvmrc is for rvm settings only.\nrvm CLI may NOT be called from within $rvmrc. \nSkipping the loading of $rvmrc"
+
+ "$rvm_path/scripts/log" "error" \
+ "$rvmrc is for rvm settings only.\nrvm CLI may NOT be called from within $rvmrc. \nSkipping the loading of $rvmrc"
+
return 1
+
else
+
source "$rvmrc"
+
fi
+
fi
+
done
return 0
}
# Wrap the specified ruby code file in a Benchmark.bmbm block and execute it.
__rvm_benchmark() {
+
+ local result old_rvm_ruby_string
+
code="require \"benchmark\" \n Benchmark.bmbm do |benchmark| \n benchmark.report(\"${rvm_ruby_file}\") do \n"
- printf "\n$code" > "$rvm_tmp_path/$$.rb"
+
+ printf "\n$code" > "${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb"
+
unset code
- cat $rvm_ruby_file >> "$rvm_tmp_path/$$.rb"
- printf "\n end \nend\n" >> "$rvm_tmp_path/$$.rb"
- rvm_ruby_args="$rvm_tmp_path/$$.rb"
+
+ cat $rvm_ruby_file >> "${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb"
+
+ printf "\n end \nend\n" >> "${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb"
+
+ rvm_ruby_args="${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb"
+
rvm_benchmark_flag=1
+
rvm_action="ruby"
- if [[ ${rvm_debug_flag:0} -gt 0 ]] ; then printf "\n$rvm_tmp_path/$$.rb:\n$(cat $rvm_tmp_path/$$.rb)" ; fi
+
+ if [[ ${rvm_debug_flag:0} -gt 0 ]] ; then
+
+ printf "\n${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb:\n$(cat ${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb)"
+
+ fi
+
# Override ruby string stuff, pass through.
- local old_rvm_ruby_string=$rvm_ruby_string
+
+ old_rvm_ruby_string=$rvm_ruby_string
+
# TODO: We can likely do this in a subshell in order to preserve the original environment?
+
unset rvm_ruby_string
+
export rvm_ruby_strings
- "$rvm_path/scripts/set" "$rvm_action" $rvm_ruby_args
- result=$?
+
+ "$rvm_path/scripts/set" "$rvm_action" $rvm_ruby_args ; result=$?
+
# Restore the state pre-sets.
[[ -n "$old_rvm_ruby_string" ]] && rvm_ruby_string=$old_rvm_ruby_string
return $result
}
# Loop over the currently installed rubies and refresh their binscripts.
__rvm_bin_scripts() {
- for rvm_ruby_binary in "$rvm_rubies_path"/*/bin/ruby ; do
+
+ for rvm_ruby_binary in "$rvm_path/rubies"/*/bin/ruby ; do
+
if [[ -x "$rvm_ruby_binary" ]] ; then
+
rvm_ruby_string=$(dirname "$rvm_ruby_binary" | xargs dirname | xargs basename)
+
__rvm_select
+
__rvm_bin_script
+
fi
+
done
+
return 0
}
# Write the bin/ wrapper script for currently selected ruby.
# TODO: Adjust binscript to be able to handle all rubies not just the standard interpreteres.
__rvm_bin_script() {
+
"$rvm_path/scripts/wrapper" "$rvm_ruby_string"
+
return $?
}
# Add bin path if not present
__rvm_conditionally_add_bin_path() {
- if echo "${PATH//:/ }" | \grep -vqF "$rvm_bin_path " ; then
- PATH="${rvm_bin_path}:$PATH"
+
+ if echo "${PATH//:/ }" | \grep -vqF "${rvm_bin_path:-"$rvm_path/bin"} " ; then
+
+ PATH="${rvm_bin_path:-"$rvm_path/bin"}:$PATH"
+
builtin hash -r
+
fi
+
return 0
}
# Reset any rvm gathered information about the system and its state.
# rvm will refresh the stored information the next time it is called after reset.
__rvm_reset() {
- __rvm_remove_rvm_from_path ; __rvm_conditionally_add_bin_path ; export PATH
+ local flag flags file files config configs variable
+
+ __rvm_remove_rvm_from_path ; __rvm_conditionally_add_bin_path
+
+ export PATH
+
builtin hash -r
- local flag=""
- for flag in default passenger editor ; do
- \rm -f "$rvm_bin_path"/${flag}_*
+ flags=( default passenger editor )
+
+ for flag in "${flags[@]}"; do
+
+ \rm -f "${rvm_bin_path:-"$rvm_path/bin"}"/${flag}_*
+
done
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}"
- done; unset file
+ [[ -f "$rvm_path/${file}" ]] && \rm -f "$rvm_path/${file}"
+
+ [[ -f "$rvm_path/config/${file}" ]] && \rm -f "$rvm_path/config/${file}"
+
+ [[ -f "$rvm_path/environments/${file}" ]] && \rm -f "$rvm_path/environments/${file}"
+
+ done
+
# 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_path/scripts/db" "$rvm_config_path/user" "$system_config" "delete"
- done ; unset system_config variable
+ configs=(system_ruby system_gem_path system_user_gem_path)
- \rm -f $rvm_bin_path/ruby $rvm_bin_path/gem $rvm_bin_path/rake $rvm_bin_path/irb $rvm_bin_path/default*
+ for system_config in "${configs[@]}" ; do
+ "$rvm_path/scripts/db" "$rvm_path/config/user" "$system_config" "delete"
+
+ done
+
+ files=(ruby gem rake irb $(cd "${rvm_bin_path:-"$rvm_path/bin"}" ; find . -iname 'default*' --mindepth 1 --maxdepth 1 -type f | sed -e 's#./##g'))
+
+ for file in "${files[@]}"; do
+
+ if [[ -f "${rvm_bin_path:-"$rvm_path/bin"}/$file" ]] ; then
+
+ \rm -f "${rvm_bin_path:-"$rvm_path/bin"}/$file"
+
+ fi
+
+ done
+
return 0
}
# Implode removes the entire rvm installation under $rvm_path.
__rvm_implode() {
+
while : ; do
- "$rvm_path/scripts/log" "warn" "Are you SURE you wish for rvm to implode? This will remove $rvm_path ? (type 'yes' or 'no')"
+ "$rvm_path/scripts/log" "warn" \
+ "Are you SURE you wish for rvm to implode? This will remove $rvm_path ? (type 'yes' or 'no')"
+
read response
if [[ "yes" = "$response" ]] ; then
+
if [[ "/" = "$rvm_path" ]] ; then
- "$rvm_path/scripts/log" "error" "remove '/' ?!... Ni!"
+
+ "$rvm_path/scripts/log" "error" \
+ "remove '/' ?!... Ni!"
+
else
+
if [[ -d "$rvm_path" ]] ; then
- "$rvm_path/scripts/log" "info" "Hai! Removing $rvm_path"
+
+ "$rvm_path/scripts/log" "info" \
+ "Hai! Removing $rvm_path"
+
\rm -rf "$rvm_path/"
+
echo "$rvm_path has been removed."
+
else
- "$rvm_path/scripts/log" "info" "It appears that $rvm_path is already non existant."
+
+ "$rvm_path/scripts/log" "info" \
+ "It appears that $rvm_path is already non existant."
+
fi
fi
break
+
elif [[ "no" = "$response" ]] ; then
- "$rvm_path/scripts/log" "info" "Cancelling implosion, no harm done :)"
+
+ "$rvm_path/scripts/log" "info" \
+ "Cancelling implosion, no harm done :)"
break
+
fi
done
return 0
}
# Output the current ruby's rvm source path.
__rvm_source_dir() {
+
if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select ; fi
if [[ -z "$rvm_ruby_src_path" ]] ; then
- "$rvm_path/scripts/log" "fail" "No source directory exists for the default implementation."
+
+ "$rvm_path/scripts/log" "fail" \
+ "No source directory exists for the default implementation."
+
else
+
echo "$rvm_ruby_src_path"
+
fi
return 0
}
@@ -561,11 +686,13 @@
rvm_ruby_load_path="."
rvm_ruby_require=""
__rvm_clean_path ; __rvm_conditionally_add_bin_path ; export PATH
- \mkdir -p "$rvm_src_path" "$rvm_bin_path" "$rvm_archives_path" "$rvm_gems_path" "$rvm_tmp_path" "$rvm_repo_path"
+ if [[ ! -d "${rvm_tmp_path:-"$rvm_path/tmp"}" ]] ; then
+ \mkdir -p "${rvm_tmp_path:-"$rvm_path/tmp"}"
+ fi
return 0
}
# Update rubygems or binscripts based on CLI selection.
@@ -589,29 +716,46 @@
}
# Update rvm using rubygems
# If --head was specified, update from git repository master branch.
__rvm_update_rvm() {
- \mkdir -p "$rvm_src_path"
(
- builtin cd "$rvm_src_path"
+ if [[ ! -d "${rvm_src_path:-"$rvm_path/src"}" ]] ; then
+ \mkdir -p "${rvm_src_path:-"$rvm_path/src"}"
+ fi
+
+ builtin cd "${rvm_src_path:-"$rvm_path/src"}"
+
if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then
- if [[ -d "$rvm_src_path/rvm/.git" ]] ; then
- builtin cd "$rvm_src_path/rvm/" && git pull origin master && ./scripts/install
+ if [[ -d "${rvm_src_path:-"$rvm_path/src"}/rvm/.git" ]] ; then
+ builtin cd "${rvm_src_path:-"$rvm_path/src"}/rvm/" && \
+ git pull origin master && \
+ ./scripts/install
+
else
- builtin cd "$rvm_src_path" && ( git clone --depth 1 git://github.com/wayneeseguin/rvm.git || git clone http://github.com/wayneeseguin/rvm.git ) && builtin cd rvm/ && ./scripts/install
+
+ builtin cd "${rvm_src_path:-"$rvm_path/src"}" && \
+ ( git clone --depth 1 git://github.com/wayneeseguin/rvm.git || \
+ git clone http://github.com/wayneeseguin/rvm.git ) && \
+ builtin cd rvm/ && ./scripts/install
fi
else
stable_version="$(curl -s http://rvm.beginrescueend.com/releases/stable-version.txt)"
- __rvm_run "fetch" "$rvm_path/scripts/fetch 'http://rvm.beginrescueend.com/releases/rvm-${stable_version}.tar.gz'" "fetching rvm-${stable_version}.tar.gz"
+ __rvm_run "fetch" \
+ "$rvm_path/scripts/fetch 'http://rvm.beginrescueend.com/releases/rvm-${stable_version}.tar.gz'" \
+ "fetching rvm-${stable_version}.tar.gz"
- __rvm_run "extract" "gunzip < \"$rvm_archives_path/rvm-${stable_version}.tar.gz\" | tar xf - -C $rvm_src_path" "Extracting rvm-${stable_version}.tar.gz ..."
+ __rvm_run "extract" \
+ "gunzip < \"${rvm_archives_path:-"$rvm_path/archives"}/rvm-${stable_version}.tar.gz\" | tar xf - -C ${rvm_src_path:-"$rvm_path/src"}" \
+ "Extracting rvm-${stable_version}.tar.gz ..."
- __rvm_run "install" "builtin cd $rvm_src_path/rvm-${stable_version}/ ; ./install" "Installing rvm-${stable_version}..."
+ __rvm_run "install" \
+ "builtin cd ${rvm_src_path:-"$rvm_path/src"}/rvm-${stable_version}/ ; ./install" \
+ "Installing rvm-${stable_version}..."
fi
)
rvm_hook="after_update" ; source "$rvm_path/scripts/hook"
@@ -679,28 +823,22 @@
return 0
}
# Output an inspection of selected 'binary' scripts, based on CLI selection.
__rvm_inspect() {
- rvm_shebang_flag=${rvm_shebang_flag:-0}
- rvm_env_flag=${rvm_env_flag:-0}
- rvm_path_flag=${rvm_path_flag:-0}
- rvm_head_flag=${rvm_head_flag:-0}
- rvm_tail_flag=${rvm_tail_flag:-0}
- rvm_all_flag=${rvm_all_flag:-0}
for binary in $rvm_ruby_args ; do
- actual_file="$(command -v $binary)"
+ actual_file="$(unset -f gem ; command -v gem )"
"$rvm_path/scripts/log" "info" "$actual_file:"
- if [[ $rvm_shebang_flag -eq 1 ]] ; then \head -n 1 < "$actual_file" ; fi
- if [[ $rvm_env_flag -eq 1 ]] ; then \awk '/ENV/' < "$actual_file" ; fi
- if [[ $rvm_path_flag -eq 1 ]] ; then \awk '/PATH/' < "$actual_file" ; fi
- if [[ $rvm_head_flag -eq 1 ]] ; then \head -n 5 < "$actual_file" ; fi
- if [[ $rvm_tail_flag -eq 1 ]] ; then \tail -n 5 < "$actual_file" ; fi
- if [[ $rvm_all_flag -eq 1 ]] ; then \cat $actual_file ; fi
+ if [[ ${rvm_shebang_flag:-0} -eq 1 ]] ; then \head -n 1 < "$actual_file" ; fi
+ if [[ ${rvm_env_flag:-0} -eq 1 ]] ; then \awk '/ENV/' < "$actual_file" ; fi
+ if [[ ${rvm_path_flag:-0} -eq 1 ]] ; then \awk '/PATH/' < "$actual_file" ; fi
+ if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then \head -n 5 < "$actual_file" ; fi
+ if [[ ${rvm_tail_flag:-0} -eq 1 ]] ; then \tail -n 5 < "$actual_file" ; fi
+ if [[ ${rvm_all_flag:-0} -eq 1 ]] ; then \cat $actual_file ; fi
done
return 0
}
@@ -740,16 +878,16 @@
return 0
}
__rvm_mono_env() {
- export DYLD_LIBRARY_PATH="$rvm_usr_path/lib:$DYLD_LIBRARY_PATH"
- export C_INCLUDE_PATH="$rvm_usr_path/include:$C_INCLUDE_PATH"
- export ACLOCAL_PATH="$rvm_usr_path/share/aclocal"
+ export DYLD_LIBRARY_PATH="${rvm_usr_path:-"$rvm_path/usr"}/lib:$DYLD_LIBRARY_PATH"
+ export C_INCLUDE_PATH="${rvm_usr_path:-"$rvm_path/usr"}/include:$C_INCLUDE_PATH"
+ export ACLOCAL_PATH="${rvm_usr_path:-"$rvm_path/usr"}/share/aclocal"
export ACLOCAL_FLAGS="-I $ACLOCAL_PATH"
- export PKG_CONFIG_PATH="$rvm_usr_path/lib/pkgconfig:$PKG_CONFIG_PATH"
- PATH="$rvm_usr_path/bin:$PATH"
+ export PKG_CONFIG_PATH="${rvm_usr_path:-"$rvm_path/usr"}/lib/pkgconfig:$PKG_CONFIG_PATH"
+ PATH="${rvm_usr_path:-"$rvm_path/usr"}/bin:$PATH"
builtin hash -r
return 0
}
@@ -762,61 +900,66 @@
return 0
}
__rvm_ensure_has_environment_files() {
- local environment_identifier="$(__rvm_environment_identifier)"
- local file_name="${rvm_environments_path}/$environment_identifier"
+ local environment_identifier file_name directory_name wrapper_identifier variable value
+ environment_identifier="$(__rvm_environment_identifier)"
+
+ file_name="${rvm_path}/environments/$environment_identifier"
+
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"
+ \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
eval "export $variable"
eval "value=\${${variable}:-""}"
if [[ -n "$value" ]] ; then
printf "${variable}='$value'\nexport ${variable}\n" >> "$file_name"
else
printf "unset ${variable}\n" >> "$file_name"
fi
- done ; unset variable value
- fi ; unset file_name
- local directory_name=""
- local wrapper_identifier=""
+ done
+ fi
+
# Next, ensure we have default wrapper files. Also, prevent it from recursing.
if [[ ${rvm_creating_default_wrappers:-0} -eq 1 ]]; 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
rvm_creating_default_wrappers=1
- directory_name="$rvm_wrappers_path/$wrapper_identifier"
+ 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
fi
+
return 0
}
# Strip whitespace and normalize it all.
__rvm_strip() {
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/[[:space:]]\{1,\}/ /g'
return $?
}
__rvm_using_gemset_globalcache() {
- "$rvm_path/scripts/db" "$rvm_config_path/user" "use_gemset_globalcache" | \grep -q '^true$'
+ "$rvm_path/scripts/db" "$rvm_path/config/user" "use_gemset_globalcache" | \grep -q '^true$'
return $?
}
__rvm_current_gemcache_dir() {
if __rvm_using_gemset_globalcache; then
@@ -842,16 +985,16 @@
return 0
}
__rvm_load_env_file() {
local string="$1"
- if [[ -f "$rvm_environments_path/$string" ]]; then
+ if [[ -f "$rvm_path/environments/$string" ]]; then
# Restore the path to it's state minus rvm
__rvm_remove_rvm_from_path
# source the environment file
- \. "$rvm_environments_path/$string"
+ \. "$rvm_path/environments/$string"
# clear the PATH cache
builtin hash -r
elif [[ -n "$string" ]] ; then
rvm "$string"
@@ -878,32 +1021,32 @@
__rvm_md5_for "$1"
return $?
}
__rvm_reset_rvmrc_trust() {
- touch "$rvm_config_path/rvmrcs"
- "$rvm_path/scripts/db" "$rvm_config_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "delete" >/dev/null 2>&1
+ touch "$rvm_path/config/rvmrcs"
+ "$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" "$(__rvm_rvmrc_key "$1")" "delete" >/dev/null 2>&1
return $?
}
__rvm_trust_rvmrc() {
- touch "$rvm_config_path/rvmrcs"
+ touch "$rvm_path/config/rvmrcs"
__rvm_reset_rvmrc_trust "$1"
- "$rvm_path/scripts/db" "$rvm_config_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "1" >/dev/null 2>&1
+ "$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" "$(__rvm_rvmrc_key "$1")" "1" >/dev/null 2>&1
return $?
}
__rvm_untrust_rvmrc() {
- touch "$rvm_config_path/rvmrcs"
+ touch "$rvm_path/config/rvmrcs"
__rvm_reset_rvmrc_trust "$1"
- "$rvm_path/scripts/db" "$rvm_config_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "0" >/dev/null 2>&1
+ "$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" "$(__rvm_rvmrc_key "$1")" "0" >/dev/null 2>&1
return $?
}
__rvm_rvmrc_stored_trust() {
- touch "$rvm_config_path/rvmrcs"
- "$rvm_path/scripts/db" "$rvm_config_path/rvmrcs" "$(__rvm_rvmrc_key "$1")"
+ touch "$rvm_path/config/rvmrcs"
+ "$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" "$(__rvm_rvmrc_key "$1")"
return $?
}
__rvm_rvmrc_tools() {
local rvmrc_action="$1"
@@ -1074,11 +1217,11 @@
[[ -z "$1" ]] && return
recorded_ruby_name="$($rvm_path/scripts/tools strings "$1")"
- rvm_install_record_file="$rvm_config_path/installs"
+ rvm_install_record_file="$rvm_path/config/installs"
rvm_install_command="$(echo "$recorded_ruby_name $rvm_install_arguments" | __rvm_strip)"
\touch "$rvm_install_record_file"
@@ -1098,11 +1241,11 @@
__rvm_remove_install_record() {
local recorded_ruby_name rvm_install_record_file
recorded_ruby_name="$($rvm_path/scripts/tools strings "$1")"
- rvm_install_record_file="$rvm_config_path/installs"
+ rvm_install_record_file="$rvm_path/config/installs"
if [[ -s "$rvm_install_record_file" ]]; then
\mv "$rvm_install_record_file" "$rvm_install_record_file.tmp"
@@ -1122,13 +1265,13 @@
[[ -z "$recorded_ruby_name" ]] && return 1
recorded_ruby_match="^$recorded_ruby_name "
- if [[ -s "$rvm_config_path/installs" ]] && \grep -q "$recorded_ruby_match" "$rvm_config_path/installs" ; then
+ if [[ -s "$rvm_path/config/installs" ]] && \grep -q "$recorded_ruby_match" "$rvm_path/config/installs" ; then
- \grep "$recorded_ruby_match" < "$rvm_config_path/installs" | head -n1
+ \grep "$recorded_ruby_match" < "$rvm_path/config/installs" | head -n1
else
return 1
fi
return $?
@@ -1170,10 +1313,10 @@
elif [[ "$string" = "current" ]]; then
__rvm_environment_identifier
elif [[ "$string" = "aliases" ]]; then
- awk -F= '{print $string}' < "$rvm_config_path/alias"
+ awk -F= '{print $string}' < "$rvm_path/config/alias"
else
echo "$string" | tr "," "\n" | __rvm_strip
fi