diff --git a/ChangeLog b/ChangeLog index 39399d664..2a92bac81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-03-04 Vladimir Serbinenko + + Use sort -V by the idea of Georgi Georgiev. + + * util/grub-mkconfig_lib.in (version_sort): New function. + (version_test_numeric): Use version_sort. + 2012-03-04 Vladimir Serbinenko Use submenus in grub-mkconfig. diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 797c69069..7e9ea1d94 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -185,6 +185,24 @@ grub_file_is_not_garbage () return 0 } +version_sort () +{ + case $version_sort_sort_has_v in + yes) + LC_ALL=C sort -V;; + no) + LC_ALL=C sort -n;; + *) + if sort -v /dev/null 2>&1; then + version_sort_sort_has_v=yes + LC_ALL=C sort -V + else + version_sort_sort_has_v=no + LC_ALL=C sort -n + fi;; + esac +} + version_test_numeric () { version_test_numeric_a="$1" @@ -201,7 +219,7 @@ version_test_numeric () version_test_numeric_a="$version_test_numeric_b" version_test_numeric_b="$version_test_numeric_c" fi - if (echo "$version_test_numeric_a" ; echo "$version_test_numeric_b") | sort -n | head -n 1 | grep -qx "$version_test_numeric_b" ; then + if (echo "$version_test_numeric_a" ; echo "$version_test_numeric_b") | version_sort | head -n 1 | grep -qx "$version_test_numeric_b" ; then return 0 else return 1