Re: Issue with ls -v / sort -V and strverscmp() usage

From:

Jim Meyering

Subject:

Re: Issue with ls -v / sort -V and strverscmp() usage

Date:

Sun, 07 Sep 2008 08:28:11 +0200

Ondřej Vašík <address@hidden> wrote:
> as reported in RH bugzilla #253817
> (https://bugzilla.redhat.com/show_bug.cgi?id=253817), there is an issue
> with ls -v (and there will be same issue with sort -V soon). Problem is
> with sorting files with extensions or dist-tags (like .tar.gz)
> because .tar.gz is more than .1.tar.gz. Therefore foo-5.0.tar.gz will be
> considered as later version than foo-5.0.1.tar.gz . As ls -v and sort -V
> now use glibc strverscmp() and this function is not going to change
> (http://sourceware.org/bugzilla/show_bug.cgi?id=3506) , I would like to
> know your opinion how to solve the issue. I see several possible ways
> how to solve it:
> 1) keep it as it is and document those limitations
> 2) to use gnulib strverscmp() for ls -v and sort -V and to modify it
> somehow to handle such cases correctly
> 3) to use/create different function for handling version sort (like
> rpmvercmp in <rpm/rpmlib.h> recommended in glibc strverscmp() bugzilla)
>
> Which way do you like? Or do you have different ideas?
IMHO, changing sort -V to produce more intuitively-correct results
is the way to go.
With ls -v, I'm willing to make the change as well, *assuming*
no one produces a counterargument.
The question is what ordering function to use.
The more generally-useful the better. i.e., I hope
it can be compatible with both the rpm and deb version sorters.