[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 09:37:01 -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 |
On 07/06/11 09:03, Chet Ramey wrote:
/usr/bin/test ?
Do this first in the binary then migrate to bash's test?
I was actually making an argument for an entirely separate utility to do
this. That could be a shell script encapsulating the proper version
comparison logic.
which basically means a script wrapping "sort -V" and testing whether
the arguments got reordered or not:
if test "X$1" = "X$3"
then is_eq=true ; is_lt=false
else
is_eq=false
first=$(printf '%s\n%s\n' "$1" "$2" | sort -V | head -1)
test "X$first" = "X$1" && is_lt=true || is_lt=false
fi
and if that proved insufficient, then "sort -V" would need an adjustment.
I would not expect "sort -V" and a version test to disagree.