bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH 2/2] do-release-commit-and-tag: use funclib.sh instead of sor


From: Paul Eggert
Subject: Re: [PATCH 2/2] do-release-commit-and-tag: use funclib.sh instead of sort -V GNUism.
Date: Sat, 26 Oct 2013 21:17:00 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0

I don't have time to review the new function library entirely,
but I see some problems with the version-number comparison.
It assumes that, for example, "test 3n -lt 4n" will succeed,
but POSIX doesn't guarantee this, and I expect some 'test'
implementations will reject that usage.

Instead of using 'cut' and 'test', how about just using sort?
That should be faster anyway.  Something like this:

printf '%s\n%s\n' "$1" "$2" |
sort -t. -k1n -k1 -k2n -k2 -k3n -k3 -k4n -k4 -k5n -k5 -k6n -k6 -k7n -k7 -k8n 
-k8 -k9n -k9

I figure 9 ought to be enough, but of course one could write
the code to work no matter how many periods are in the version
numbers, without invoking any more processes than these two.

Also, this:

 newer_ver=$(func_sort_ver $prev_ver $ver |cut -d' ' -f2)
 test "$newer_ver" != "$ver" && \
  die "invalid version: $ver (<= $prev_ver)"

looks awkward.  Instead, how about having
a function func_lt_ver that succeeds if its first
argument is less than the second?  That way, one can
simply write:

  func_lt_ver "$prev_ver" "$ver" ||
    die "invalid version: $ver (<= $prev_ver)"

which is simpler and is more robust in the presence of
oddities like spaces in version numbers.



reply via email to

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