scripts/utility in rvm-0.1.41 vs scripts/utility in rvm-0.1.42
- old
+ new
@@ -22,10 +22,21 @@
:
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 [[ -n "$rvm_clang_flag" ]] ; then
+ if [[ -n "$rvm_prior_cc" ]] ; then
+ export CC="$rvm_prior_cc"
+ else
+ unset CC
+ fi
+ unset rvm_prior_cc
+ fi
+
unset rvm_ruby_strings
}
# Return a list of directories under a given base path.
# Derived from rvm_ruby_string.
@@ -63,12 +74,12 @@
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")'"
+ 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'
@@ -167,11 +178,11 @@
__rvm_cleanup_variables() {
__rvm_unset_ruby_variables
if [[ "$rvm_sticky_flag" = "1" ]] ; then export rvm_gemset_name ; else unset rvm_gemset_name ; fi
- unset rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_url 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_ruby_aliases rvm_patch_names
+ unset rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_url 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_ruby_aliases rvm_patch_names rvm_clang_flag
}
# 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
@@ -496,26 +507,22 @@
# This is only an issue with Darwin :/
if [[ "Darwin" = "$(uname)" ]] ; then
# \ls /usr/lib/gcc/x86_64-apple-darwin10
# Set the build & host type
- if [[ "Power Macintosh" = "$(sysctl hw.machine | awk -F: '{print $2}' | sed 's/^ //')" ]] ; then
+ if [[ "Power Macintosh" = "$(sysctl -n hw.machine)" ]] ; then
: # Do nothing ?
- elif [[ $(sysctl hw.cpu64bit_capable | awk '{print $2}') = 1 ]] ; then # we could also use: sysctl hw.optional.x86_64
+ 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)"
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)"
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)"
fi
- else
- # 32 bit capable only
- if [[ -z "$rvm_archflags" ]] ; then rvm_archflags="-arch i386" ; fi
- rvm_ruby_configure_flags="${rvm_ruby_configure_flags} --build=i386-apple-darwin$(uname -r) --host=i386-apple-darwin$(uname -r)"
fi
if [[ ! -z "$rvm_archflags" ]] ; then
ARCHFLAGS="$rvm_archflags" ; export ARCHFLAGS
# Use the latest sdk available.
@@ -703,18 +710,20 @@
fi
done ; unset variable value
fi ; unset file_name
# Next, ensure we have default wrapper files. Also, prevent it from recursing.
if [[ -z "$rvm_creating_default_wrappers" ]]; 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/$environment_identifier"
+ directory_name="$rvm_wrappers_path/$wrapper_identifier"
if [[ ! -L "$directory_name" && ! -d "$directory_name" ]]; then
mkdir -p "$directory_name"
- # Install the default wrappers.
- $rvm_scripts_path/wrapper "$environment_identifier" &> /dev/null
+ $rvm_scripts_path/wrapper "$wrapper_identifier" &> /dev/null
fi
unset rvm_creating_default_wrappers directory_name
+ done; unset wrapper_identifier
fi
}
# Strip whitespace and normalize it all.
__rvm_strip() {
@@ -742,5 +751,38 @@
printf "\nhowever I can help you build a more "
printf "\npowerful Ruby which can compute the "
printf "\nUltimate Question."
}
+# 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 [[ -n "$rvm_rvmrc_cwd" ]] ; then
+ if [[ -z "$rvm_previous_environment" ]] ; then
+ rvm default 1>/dev/null 2>&1
+ else
+ rvm "$rvm_previous_environment" 1>/dev/null 2>&1
+ 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_rvmrc_cwd="$cwd"
+ source "$cwd/.rvmrc"
+ fi
+ break
+ else
+ cwd=$(dirname "$cwd")
+ fi
+ fi
+ done
+}