Hi,

CF: a thread from bug-bash:

On 07/06/11 06:38, Chet Ramey wrote:
On 7/5/11 8:59 AM, Bruce Korb wrote:

Given that sort(1GNU) now has a sort-by-version-ordering (sort -V),
it would seem reasonable to do version comparisons without having
to do a series of fork & execs.  In other words, abbreviate this:

    min_os_ver=`
      printf '2.6.27\n%s\n' "$LINUXRELEASE" | sort -V | head -1`
    if test "X$min_os_ver" = "X2.6.27" ; then

into something like this:

    if test "2.6.27" -Vle "$LINUXRELEASE" ; then

or add a different operator to [[ ]] contexts?

The issue is extremely nontrivial.

The normal case is to sort full releases.  The goal in "sort -V" was to make
the usual case easy, not to make the authoritative solution for an intractable
problem. [...]  In my little world, it would be quite convenient.

This is an excellent argument for a utility to perform version comparisons.
Such a program could be arbitrarily complex.  This feature is too new to
know how it will evolve.

/usr/bin/test ?

Do this first in the binary then migrate to bash's test?

Reply via email to