scripts/utility in rvm-1.0.5 vs scripts/utility in rvm-1.0.6
- old
+ new
@@ -46,46 +46,61 @@
return 0
}
# Dump the current environment to a file.
__rvm_dump_environment() {
+
# Note: This assumes that there is a ','
- local dump_environment_file="${rvm_dump_environment_flag/,*/}"
- local dump_environment_type="${rvm_dump_environment_flag/*,/}"
+ local dump_environment_file dump_environment_type rvm_dump_environment_flag
+
+ dump_environment_file="${rvm_dump_environment_flag/,*/}"
+
+ dump_environment_type="${rvm_dump_environment_flag/*,/}"
+
if [[ -n "$dump_environment_file" && -n "$dump_environment_type" ]]; then
+
if [[ "$dump_environment_type" == "atheis"* ]] && [[ -f "$dump_environment_file" ]] ; then
# TODO: Query Darcy about the ln.
\rm -f "$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"
- if [[ "$?" -gt 0 ]] && [[ -f "$dump_environment_file" ]] ; then
+ if [[ "$?" -gt 0 && -f "$dump_environment_file" ]] ; then
\rm -f "$dump_environment_file"
fi
fi
- fi ; unset rvm_dump_environment_flag
+ fi
+
return 0
}
# Return a list of directories under a given base path.
# Derived from rvm_ruby_string.
__rvm_ruby_string_paths_under() {
- local path="$1"
- local path_parts="${rvm_ruby_string//-/ }"
+ local path path_parts
+ path="$1"
+
+ path_parts="${rvm_ruby_string//-/ }"
+
while true ; do
+
echo "$path/$path_parts" | sed -e 's# #/#g' -e 's#/$##g'
+
[[ -z "$path_parts" ]] && break
+
path_parts="$(echo "$path_parts" | awk '{$NF=""; print}' | __rvm_strip)"
+
done
return 0
}
# Query the rvm key-value database for a specific key
# Allow overrides from user specifications in $rvm_config_path/user
__rvm_db() {
- local value="" key="" variable=""
+ local value key variable
key=${1:-""}
variable=${2:-""}
if [[ -f "$rvm_config_path/user" ]] ; then
@@ -109,87 +124,127 @@
is_a_function() { type $1 | head -n 1 | \grep -q "function" ; }
__rvm_quote_args() {
local quoted_string=""
+
for quoted_argument in "$@"; do
+
if printf "%s" "$quoted_argument" | \grep -vq "^[[:alnum:]]$"; then
+
quoted_string="$quoted_string '$(printf "%s" "$quoted_argument" | sed "s/'/\'\\\'\'/g")'"
+
else
quoted_string="$quoted_string $quoted_argument"
fi
done
+
echo "$quoted_string" | sed -e 's/^ *//g' -e 's/ *$//g'
+
return 0
}
__rvm_quote_args_with_shift() {
+
local shift_value="$1"; shift
- while [[ "$shift_value" -gt 0 && "$#" -gt 0 ]]; do
- shift ; ((shift_value--))
+
+ while [[ "$shift_value" -gt 0 && $# -gt 0 ]]; do
+
+ shift
+
+ ((shift_value--))
+
done
+
__rvm_quote_args "$@"
+
return 0
}
__rvm_warn_on_rubyopt() {
- if [[ -n "$RUBYOPT" ]]; then
- "$rvm_scripts_path"/log "warn" "Please note: You have the RUBYOPT environment variable set and this may interfere with normal rvm operations. We sugges unsetting it."
+
+ if [[ -n "${RUBYOPT:-""}" ]]; then
+ "$rvm_scripts_path"/log "warn" \
+ "Please note: You have the RUBYOPT environment variable set and this may interfere with normal rvm operations. We sugges unsetting it."
return 1
else
return 0
fi
}
__rvm_strings() {
- local strings=""
- for rvm_ruby_string in $(echo ${rvm_ruby_args:-$rvm_ruby_string}) ; do
+ local strings ruby_strings
+
+ ruby_strings=($(echo ${rvm_ruby_args:-$rvm_ruby_string}))
+
+ for rvm_ruby_string in "${ruby_strings[@]}" ; do
strings="$strings $(__rvm_select ; echo $rvm_ruby_string)"
done
+
echo $strings
+
return 0
}
# Push an item onto a given array.
__rvm_push() {
+
+ local array item
+
array=$1 ; shift ; item=$2
+
# TODO: allow loop over more arguments.
eval "index=\$((\${#${array}[*]} + $__shell_array_start))"
+
eval "${array}[${index}]=${item}"
- unset array item
+
+ return 0
}
__rvm_set_path_variable() {
+
if [[ -d "$1" ]] ; then
eval "${path_variable}=${1}"
+
else
- "$rvm_scripts_path/log" "error" "'$1' is not a valid path."
- fi ; unset path_variable
+ "$rvm_scripts_path/log" "error" \
+ "'$1' is not a valid path."
+ unset path_variable
+ fi
+
+ return 0
}
# Clean all *duplicate* items out of the path. (keep first occurrence of each)
__rvm_clean_path() {
PATH="$(echo $PATH | \tr -s ':' '\n' | awk '!($0 in a){a[$0];print}' | \tr -s '\n' ':' | sed 's#:$##')"
+
export PATH
+
builtin hash -r
}
# Clean all rvm items out of the current working path.
__rvm_remove_rvm_from_path() {
- PATH="$(echo $PATH | \tr -s ':' '\n' | \grep -v "$rvm_path" | \tr -s '\n' ':' | sed 's#:$##')"
+ PATH="${PATH//${rvm_path}*rvm\/bin:}"
+
export PATH
+
builtin hash -r
}
# Run a specified command and log it.
__rvm_run() {
- local log_file_name="${1:-""}"
- local command="${2:-""}"
- local message="${3:-""}"
- if [[ -z "$rvm_ruby_log_path" ]] ; then rvm_ruby_log_path="$rvm_log_path" ; fi
+ local 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_scripts_path/log" "info" "$message" ; fi
if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
"$rvm_scripts_path/log" "debug" "Executing: $command"
fi
@@ -205,24 +260,30 @@
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
fi
)
- local result=$? ; if [[ $result -gt 0 ]] ; then
- "$rvm_scripts_path/log" "error" "Error running '$command', please check $rvm_ruby_log_path/$log_file_name*.log"
+ local result=$?
+
+ if [[ $result -gt 0 ]] ; then
+ "$rvm_scripts_path/log" "error" \
+ "Error running '$command', please check $rvm_ruby_log_path/$log_file_name*.log"
fi
return $result
}
# Runs a command in a given env.
__rvm_run_with_env() {
- local log_file_name="${1:-""}"
- local env_name="${2:-""}"
- local command="${3:-""}"
- local message="${4:-""}"
+ local 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_scripts_path/log" "info" "$message" ; fi
@@ -242,12 +303,15 @@
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
)
- result=$? ; if [[ $result -gt 0 ]] ; then
- "$rvm_scripts_path/log" "error" "Error running '$command' under $env_name, please check $rvm_ruby_log_path/$log_file_name*.log"
+ result=$?
+
+ if [[ $result -gt 0 ]] ; then
+ "$rvm_scripts_path/log" "error" \
+ "Error running '$command' under $env_name, please check $rvm_ruby_log_path/$log_file_name*.log"
fi
return $result
}
@@ -255,64 +319,86 @@
unset rvm_head_flag $(env | awk -F= '/^rvm_/{print $1" "}')
}
# Unset ruby-specific variables
__rvm_unset_ruby_variables() {
- unset rvm_head_flag $(env | awk -F= '/^rvm_ruby_/{printf $1" "}')
+ unset rvm_ruby_flag $(env | awk -F= '/^rvm_ruby_/{printf $1" "}')
}
# TODO: Should be able to...
# 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_cleanse_variables() {
__rvm_unset_ruby_variables
if [[ ${rvm_sticky_flag:-0} -eq 1 ]] ; then export rvm_gemset_name ; else unset rvm_gemset_name ; fi
- unset rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_force_flag rvm_all_flag rvm_reconfigure_flag rvm_make_flags rvm_bin_flag rvm_import_flag rvm_export_flag rvm_self_flag rvm_gem_flag rvm_rubygems_flag rvm_debug_flag rvm_delete_flag rvm_summary_flag rvm_test_flag _rvm_spec_flag rvm_json_flag rvm_yaml_flag rvm_shebang_flag rvm_env_flag rvm_tail_flag rvm_use_flag rvm_dir_flag rvm_list_flag rvm_empty_flag rvm_file_name rvm_benchmark_flag rvm_clear_flag rvm_name_flag rvm_verbose_flag rvm_user_flag rvm_system_flag rvm_ruby_configure_flags rvm_uninstall_flag rvm_install_flag rvm_llvm_flag rvm_ruby_bits rvm_sticky_flag rvm_rvmrc_flag rvm_gems_flag rvm_only_path_flag rvm_docs_flag rvm_ruby_aliases rvm_patch_names rvm_clang_flag rvm_install_arguments rvm_dump_environment_flag rvm_ruby_alias
+ unset rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_force_flag rvm_all_flag rvm_reconfigure_flag rvm_make_flags rvm_bin_flag rvm_import_flag rvm_export_flag rvm_self_flag rvm_gem_flag rvm_rubygems_flag rvm_debug_flag rvm_delete_flag rvm_summary_flag rvm_test_flag _rvm_spec_flag rvm_json_flag rvm_yaml_flag rvm_shebang_flag rvm_env_flag rvm_tail_flag rvm_use_flag rvm_dir_flag rvm_list_flag rvm_empty_flag rvm_file_name rvm_benchmark_flag rvm_clear_flag rvm_name_flag rvm_verbose_flag rvm_user_flag rvm_system_flag rvm_configure_flags rvm_uninstall_flag rvm_install_flag rvm_llvm_flag rvm_ruby_bits rvm_sticky_flag rvm_rvmrc_flag rvm_gems_flag rvm_only_path_flag rvm_docs_flag rvm_ruby_aliases rvm_patch_names rvm_clang_flag rvm_install_arguments rvm_dump_environment_flag rvm_ruby_alias
}
# Usage: __rvm_with_env 'env-name' 'command'
__rvm_with_env() {
- local environment_id="$1" command="$2"
- ( rvm use "$environment_id" ; eval "$command" )
+ local environment_id command
+
+ environment_id="$1"
+ command="$2"
+
+ (
+ 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=""
- for ruby_name in $(\ls "$rvm_rubies_path"); do
- if [[ ! -L "$rvm_rubies_path/$ruby_name" ]] && [[ "$ruby_name" =~ 1.8. || "$ruby_name" =~ rbx- || "$ruby_name" =~ ree- ]] ; then
- rubies="$rubies $ruby_name"
+ local rubies ruby_name
+
+ rubies=($( cd "$rvm_rubies_path" ; find * -type d -maxdepth 0 ))
+
+ for ruby_name in "${rubies[@]}"; do
+
+ if [[ ! -L "$rvm_rubies_path/$ruby_name" ]] ; then
+
+ case $ruby_name in
+ *1.8.*|rbx-*|ree-*) rubies="$rubies $ruby_name" ;;
+ esac
fi
- done; unset ruby_name
+ done
- echo "$rubies" | sed 's/^ //' | \tr ' ' '\n' | sort | tail -n1
+ echo $rubies | \tr ' ' '\n' | \sort | \tail -n1
return 0
}
__rvm_ensure_has_18_compat_ruby() {
+
if [[ -z "$(__rvm_18_compat_ruby)" ]]; then
# TODO: install currently doesn't return the correct status.
local compat_result=0
+
if ! ( "$rvm_scripts_path/manage" install 1.8.7 ); then
- "$rvm_scripts_path/log" "fail" "To proceed rvm requires a 1.8-compatible ruby is installed. We attempted to install 1.8.7 automatically but it failed."
- "$rvm_scripts_path/log" "fail" "Please install it manually (or a compatible alternative) to proceed."
+
+ "$rvm_scripts_path/log" "fail" \
+ "To proceed rvm requires a 1.8-compatible ruby is installed. We attempted to install 1.8.7 automatically but it failed.\
+ Please install it manually (or a compatible alternative) to proceed."
+
compat_result=1
- fi ; unset original_ruby
- # TODO: Why are we unsetting original_ruby here
+
+ fi
+ # unset original_ruby
+ # Question: Why *were* we unsetting original_ruby here
return $compat_result
fi
return 0
}
# Cleans up temp folders for a given prefix,
# typically the current process id.
__rvm_cleanup_temp_for() {
+
local prefix="$1"
[[ -z "$prefix" ]] && return 1
if [[ -d "$rvm_tmp_path/" ]]; then
@@ -522,12 +608,14 @@
__rvm_update_rvm() {
\mkdir -p "$rvm_src_path"
(
builtin cd "$rvm_src_path"
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
+
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
fi
else
stable_version="$(curl -s http://rvm.beginrescueend.com/releases/stable-version.txt)"
@@ -618,16 +706,16 @@
for binary in $rvm_ruby_args ; do
actual_file="$(command -v $binary)"
"$rvm_scripts_path/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 -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
done
return 0
}
@@ -642,24 +730,24 @@
if [[ "Power Macintosh" = "$(sysctl -n hw.machine)" ]] ; then
: # Do nothing ?
elif [[ "$(sysctl -n hw.cpu64bit_capable)" = 1 || "$(sysctl -n hw.optional.x86_64)" = 1 ]] ; then
# 64 bit capable
if [[ "-arch x86_64" = "${rvm_archflags:-""}" ]] ; then
- rvm_ruby_configure_flags="${rvm_ruby_configure_flags} --build=x86_64-apple-darwin$(uname -r) --host=x86_64-apple-darwin$(uname -r)"
+ rvm_configure_flags="${rvm_configure_flags} --build=x86_64-apple-darwin$(uname -r) --host=x86_64-apple-darwin$(uname -r)"
elif [[ "-arch i386" = "${rvm_archflags:-""}" ]] ; then
- rvm_ruby_configure_flags="${rvm_ruby_configure_flags} --build=i386-apple-darwin$(uname -r) --host=i386-apple-darwin$(uname -r)"
+ rvm_configure_flags="${rvm_configure_flags} --build=i386-apple-darwin$(uname -r) --host=i386-apple-darwin$(uname -r)"
else
rvm_archflags="-arch x86_64"
- rvm_ruby_configure_flags="${rvm_ruby_configure_flags} --build=x86_64-apple-darwin$(uname -r) --host=x86_64-apple-darwin$(uname -r)"
+ rvm_configure_flags="${rvm_configure_flags} --build=x86_64-apple-darwin$(uname -r) --host=x86_64-apple-darwin$(uname -r)"
fi
fi
if [[ -n "${rvm_archflags:-""}" ]] ; then
ARCHFLAGS="$rvm_archflags" ; export ARCHFLAGS
# Use the latest sdk available.
if [[ -z "${rvm_sdk:-""}" ]] ; then
- rvm_sdk="$(/usr/bin/basename -a /Developer/SDKs/* | awk '/^M/' | sort | tail -n 1)"
+ rvm_sdk="$(/usr/bin/basename -a /Developer/SDKs/* | awk '/^M/' | \sort | \tail -n 1)"
fi
CFLAGS="${CFLAGS:-"-isysroot /Developer/SDKs/$rvm_sdk $rvm_archflags"}" ; export CFLAGS
LDFLAGS="${LDFLAGS:-"-Wl,-syslibroot /Developer/SDKs/$rvm_sdk $rvm_archflags"}" ; export LDFLAGS
# CXXFLAGS="-mmacosx-version-min="$(sw_vers -productVersion | awk -F'.' '{print $1"."$2}')" -isysroot /Developer/SDKs/$rvm_sdk " ; export CXXFLAGS
fi
@@ -881,11 +969,15 @@
fi
return $?
}
__rvm_ask_to_trust() {
+
+ local trusted value
+
[[ -n "$rvm_promptless" ]] && return 2
+
printf "
============================================================
RVM has encountered a not yet trusted .rvmrc file in the
current working directory which contains the following code:
============================================================
@@ -897,26 +989,34 @@
directory RVM will excecute this .rvmrc script in your shell
Do you wish to trust this .rvmrc from now on?
============================================================
(y for yes, n for no)"
- local trusted=""
+
# TODO: Eliminate infinite loop possibility.
while [[ -z "$trusted" ]] ; do
+
printf " > "
+
read -r response
+
value="$(echo "$response" | tr '[[:upper:]]' '[[:lower:]]' | __rvm_strip)"
+
if [[ "$response" = "y"* ]]; then
trusted=1
+
elif [[ "$response" = "n"* ]]; then
trusted=0
fi
- done ; unset value
+ done
- if [[ "$trusted" == "1" ]] ; then
+ if [[ ${trusted:-0} -gt 0 ]] ; then
+
__rvm_trust_rvmrc "$1"
+
return 0
+
else
__rvm_untrust_rvmrc "$1"
return 1
fi
}
@@ -928,119 +1028,170 @@
# 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 [[ ${rvm_project_rvmrc_default:-0} -eq 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
__rvm_check_rvmrc_trustworthiness "$cwd/.rvmrc"
local rvm_trustworthiness_result="$?"
if [[ "$rvm_trustworthiness_result" = 0 ]]; then
+
rvm_previous_environment="$(__rvm_environment_identifier)"
+
rvm_rvmrc_cwd="$cwd"
+
source "$cwd/.rvmrc"
- return 0
+ return 0
else
return "$rvm_trustworthiness_result"
fi
fi
break
+
else
cwd="$(dirname "$cwd")"
fi
fi
done
+
return $?
}
__rvm_record_install() {
+
+ local recorded_ruby_name rvm_install_record_file rvm_install_command
+
[[ -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)"
+
+ recorded_ruby_name="$($rvm_scripts_path/tools strings "$1")"
+
+ rvm_install_record_file="$rvm_config_path/installs"
+
+ rvm_install_command="$(echo "$recorded_ruby_name $rvm_install_arguments" | __rvm_strip)"
+
\touch "$rvm_install_record_file"
+
\rm -f "$rvm_install_record_file.tmp"
+
\grep -v "^$recorded_ruby_name " < "$rvm_install_record_file" > "$rvm_install_record_file.tmp"
+
echo "$rvm_install_command" >> "$rvm_install_record_file.tmp"
+
\rm -f "$rvm_install_record_file"
+
\mv "$rvm_install_record_file.tmp" "$rvm_install_record_file"
+
+ return 0
}
__rvm_remove_install_record() {
- local recorded_ruby_name="$($rvm_scripts_path/tools strings "$1")"
- local rvm_install_record_file="$rvm_config_path/installs"
+ local recorded_ruby_name rvm_install_record_file
+
+ recorded_ruby_name="$($rvm_scripts_path/tools strings "$1")"
+
+ 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"
+
\grep -v "^$recorded_ruby_name " < "$rvm_install_record_file.tmp" > "$rvm_install_record_file"
+
\rm -f "$rvm_install_record_file.tmp"
fi
+
return 0
}
__rvm_recorded_install_command() {
- local recorded_ruby_name="$($rvm_scripts_path/tools strings "$1" | awk -F"$rvm_gemset_separator" '{print $1}')"
+
+ local recorded_ruby_name recorded_ruby_match
+
+ recorded_ruby_name="$($rvm_scripts_path/tools strings "$1" | awk -F"$rvm_gemset_separator" '{print $1}')"
+
[[ -z "$recorded_ruby_name" ]] && return 1
- local recorded_ruby_match="^$recorded_ruby_name "
+
+ recorded_ruby_match="^$recorded_ruby_name "
+
if [[ -s "$rvm_config_path/installs" ]] && \grep -q "$recorded_ruby_match" "$rvm_config_path/installs" ; then
+
\grep "$recorded_ruby_match" < "$rvm_config_path/installs" | head -n1
+
else
return 1
fi
return $?
}
__rvm_environment_identifier() {
- local path
- local string
+
+ local path string
+
path="${GEM_HOME:-""}"
+
string="${path//*gems\//}"
string="${string//\/*/}"
+
echo "${string:-system}"
+
return $?
}
__rvm_expand_ruby_string() {
+
local string="$1"
if [[ -z "$string" || "$string" = "all" ]]; then
- "$rvm_scripts_path/list" strings | tr ' ' "\n" | __rvm_strip
+ "$rvm_scripts_path/list" strings | tr ' ' "\n"
elif [[ "$string" = "all-gemsets" ]]; then
- "$rvm_scripts_path/list" gemsets strings | __rvm_strip
+ "$rvm_scripts_path/list" gemsets strings
elif [[ "$string" = "default-with-rvmrc" || "$string" = "rvmrc" ]]; then
"$rvm_scripts_path/tools" path-identifier "$PWD"
elif [[ "$string" == "all-rubies" || "$string" = "rubies" ]]; then
- "$rvm_scripts_path/list" rubies strings | __rvm_strip
+ "$rvm_scripts_path/list" rubies strings
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_scripts_path/gemsets" list | sed "s/^/$current_ruby$rvm_gemset_separator/" | __rvm_strip
+ rvm_silence_logging=1 "$rvm_scripts_path/gemsets" list | sed "s/^/$current_ruby$rvm_gemset_separator/"
elif [[ "$string" = "current" ]]; then
__rvm_environment_identifier
elif [[ "$string" = "aliases" ]]; then
- awk -F= '{print $string}' < "$rvm_config_path/alias" | __rvm_strip
+ awk -F= '{print $string}' < "$rvm_config_path/alias"
else
+
echo "$string" | tr "," "\n" | __rvm_strip
fi
return $?
}