coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Yet Another test option


From: Bruce Korb
Subject: Re: Yet Another test option
Date: Wed, 06 Jul 2011 08:45:38 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110616 SUSE/3.1.11 Thunderbird/3.1.11

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

[Prev in Thread] Current Thread [Next in Thread]