Skip to content

Commit

Permalink
use more of __rvm_version_sort, fix #2676
Browse files Browse the repository at this point in the history
  • Loading branch information
mpapis committed Mar 7, 2014
1 parent 25a89fe commit 6e7a959
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 16 deletions.
3 changes: 2 additions & 1 deletion scripts/functions/build
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ __rvm_mri_rubies()
# with things like rbx etc which require a ruby be installed.
__rvm_mri_ruby()
{
__rvm_mri_rubies "${1:-"ruby-1.9|ruby-2"}" | sort |
__rvm_mri_rubies "${1:-"ruby-1.9|ruby-2"}" |
__rvm_version_sort |
__rvm_awk 'BEGIN{ selected=$0 } /'"$(__rvm_env_string)"'/{ selected=$0 } END {print $0}'
}

Expand Down
12 changes: 8 additions & 4 deletions scripts/functions/build_config_system
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ __rvm_setup_compile_environment_system_BSD()
then
export AUTOCONF_VERSION
AUTOCONF_VERSION="$(
ls -1 /usr/local/bin/autoreconf-* | __rvm_awk -F- '{print $NF}' |
__rvm_version_sort | __rvm_tail -n 1
ls -1 /usr/local/bin/autoreconf-* |
__rvm_awk -F- '{print $NF}' |
__rvm_version_sort |
__rvm_tail -n 1
)"
fi
if
Expand All @@ -121,8 +123,10 @@ __rvm_setup_compile_environment_system_BSD()
export AUTOMAKE_VERSION
# FreeBSD might have automake-wrapper
AUTOMAKE_VERSION="$(
ls -1 /usr/local/bin/automake-1* | __rvm_awk -F- '{print $NF}' |
__rvm_version_sort | __rvm_tail -n 1
ls -1 /usr/local/bin/automake-1* |
__rvm_awk -F- '{print $NF}' |
__rvm_version_sort |
__rvm_tail -n 1
)"
fi
}
Expand Down
4 changes: 3 additions & 1 deletion scripts/functions/build_requirements_helpers
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ requirements_version_minimal()
then return 0
fi
typeset latest_version="$(
requirements_${__lib_type}_version_list $1 | __rvm_version_sort | __rvm_tail -n 1
requirements_${__lib_type}_version_list $1 |
__rvm_version_sort |
__rvm_tail -n 1
)"
if
[[ -z "${latest_version}" ]] ||
Expand Down
4 changes: 3 additions & 1 deletion scripts/functions/requirements/osx_port
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ requirements_osx_port_install_port()
macports_version="$(
__rvm_curl https://distfiles.macports.org/MacPorts/ |
__rvm_grep -Eo "<a href=\"MacPorts-[[:digit:]\.]+.tar.bz2\">" |
__rvm_awk -F'"' '{print $2}' | sort | __rvm_tail -n 1
__rvm_awk -F'"' '{print $2}' |
__rvm_version_sort |
__rvm_tail -n 1
)" #'
macports_version="${macports_version%.tar.bz2}"
: macports_version:${macports_version:=MacPorts-2.1.3}
Expand Down
6 changes: 3 additions & 3 deletions scripts/functions/selector
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ __rvm_ruby_string_autodetect()
__rvm_list_strings |
__rvm_grep "^${rvm_ruby_interpreter}-.*${rvm_ruby_name:-}" |
__rvm_awk -F- '{print $2}' |
\sort |
__rvm_version_sort |
__rvm_tail -n 1
)"
fi
Expand Down Expand Up @@ -410,7 +410,7 @@ __rvm_ruby_string_autodetect()
new_ruby_string="$(
__rvm_list_strings |
__rvm_grep "^${rvm_ruby_string}.*${rvm_ruby_name:-}" |
\sort |
__rvm_version_sort |
__rvm_tail -n 1
)"
rvm_ruby_string="${new_ruby_string:-$rvm_ruby_string}"
Expand All @@ -436,7 +436,7 @@ __rvm_ruby_string_autodetect()
__rvm_list_strings |
__rvm_grep "^${rvm_ruby_interpreter}-${rvm_ruby_version}-.*${rvm_ruby_name:-}" |
__rvm_awk -F- '{print $3}' |
\sort |
__rvm_version_sort |
__rvm_tail -n 1
)"
fi
Expand Down
4 changes: 3 additions & 1 deletion scripts/functions/selector_interpreters
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ __rvm_select_macruby_nightly_detect()
rvm_ruby_version="$(
__rvm_curl -s "$rvm_ruby_url" |
__rvm_grep -oE "<a href=\"macruby_nightly-[^<]+\.pkg</a>" |
__rvm_awk -F"[<>]" '{print $3}' | sort | __rvm_tail -n 1
__rvm_awk -F"[<>]" '{print $3}' |
__rvm_version_sort |
__rvm_tail -n 1
)"
[[ -n "${rvm_ruby_version}" ]] ||
{
Expand Down
3 changes: 2 additions & 1 deletion scripts/functions/selector_late
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ __rvm_select_late_rbx_partial()
__found="$(
__rvm_curl -s $1/index.txt "rubinius-$1" |
__rvm_awk -F"${__ext}" "/${__patern}/"'{print $1}' |
\sort | \tail -n 1
__rvm_version_sort |
__rvm_tail -n 1
)"
if
[[ -n "${__found}" ]]
Expand Down
10 changes: 7 additions & 3 deletions scripts/functions/selector_parse
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ __rvm_ruby_string_fuzzy_remote_for()
new_ruby_string="$(
__list_remote_$1_for $( __rvm_system_path_for ${2:-$1} ) |
__rvm_awk -F/ '{x=$NF; gsub(".tar.*","",x); gsub("jruby-bin","jruby",x); print x}' |
\sort -V |
__rvm_version_sort |
__rvm_awk '
BEGIN{found=""; any=""}
/^'"${__search}"'$/ {found=$1}
Expand Down Expand Up @@ -36,7 +36,10 @@ __rvm_ruby_string_fuzzy()
then __search="${__search%${rvm_ruby_name:-}}.*${rvm_ruby_name:-}"
fi
new_ruby_string="$(
__rvm_list_strings | __rvm_grep "${__search}" | \sort | __rvm_tail -n 1
__rvm_list_strings |
__rvm_grep "${__search}" |
__rvm_version_sort |
__rvm_tail -n 1
)"
if [[ -n "${new_ruby_string}" ]]
then rvm_ruby_string="${new_ruby_string}"
Expand Down Expand Up @@ -255,7 +258,8 @@ __rvm_ruby_string_latest()
new_ruby_string="$(
\cat "$rvm_path/config/known_strings" |
__rvm_grep "${check_ruby_string}" |
sort | __rvm_tail -n 1
__rvm_version_sort |
__rvm_tail -n 1
)"
if
[[ -n "${new_ruby_string}" ]]
Expand Down
2 changes: 1 addition & 1 deletion scripts/functions/utility
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ __rvm_detect_xcode_version_at_least()
# TODO: better semver support
__rvm_version_sort()
{
LC_ALL=C sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n
LC_ALL=C \sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n
}

__rvm_version_compare()
Expand Down

0 comments on commit 6e7a959

Please sign in to comment.