[Toybox] sort -V

enh enh at google.com
Wed Dec 19 12:14:31 PST 2018


On Wed, Dec 19, 2018 at 12:00 PM Rob Landley <rob at landley.net> wrote:
>
> On 12/19/18 1:41 PM, enh via Toybox wrote:
> > it turns out that we have a few users of `sort -V`. i'd always assumed
> > this meant "use the GNU strverscmp(3) function as your comparator" but
> > no, it's slightly different...
> >
> > https://www.gnu.org/software/coreutils/manual/html_node/Details-about-version-sort.html
>
> That's really unpleasant.
>
> > the first github match for that function says this:
> >
> >   This implements the algorithm for comparison of version strings
> >   specified by Debian and now widely adopted. The detailed
> >   specification can be found in the Debian Policy Manual in the
> >   section on the 'Version' control field. This version of the code
> >   implements that from s5.6.12 of Debian Policy v3.8.0.1
> >   http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version
>
> That's outright insane.
>
> > at which point i _wish_ it was just the stupid strverscmp...
>
> While I have some experience in this area:
>
> https://github.com/landley/aboriginal/blob/master/sources/functions.sh#L248
>
> It's not a happy thing.
>
> What is the _context_ of the users of sort -V? If I do try to implement
> something, what does success look like here? (Do we have a sort.test patch we
> can start with?)

from most legit to least legit...

someone trying to find the latest kernel version from git tags:

https://android.googlesource.com/platform/tools/repohooks/+/master/tools/checkpatch.pl-update

there also appears to be something directly in the kernel:

https://android.googlesource.com/kernel/common/+/android-3.10/scripts/depmod.sh

plus the usual suspects sort a directory of files called 0_foo, 1_bar,
etc, (where the number always comes first) apparently with no need for
-V at all.

so really just kernel version tags?

> Rob
>
> P.S. Still trying to finish grep --color, probably not getting to this today...


More information about the Toybox mailing list