GNU bug report logs - #35939
version sort is incorrect with hyphen-minus

Previous Next

Package: coreutils;

Reported by: Vincent Lefevre <vincent <at> vinc17.net>

Date: Tue, 28 May 2019 00:55:01 UTC

Severity: normal

Full log


Message #17 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Vincent Lefevre <vincent <at> vinc17.net>
To: Assaf Gordon <assafgordon <at> gmail.com>
Cc: bug-coreutils <at> gnu.org, Ian Jackson <ijackson <at> chiark.greenend.org.uk>
Subject: Re: bug#35939: version sort is incorrect with hyphen-minus
Date: Wed, 26 Jun 2019 22:14:54 +0200
On 2019-06-26 12:25:26 -0600, Assaf Gordon wrote:
> "ls -v" and "sort -V" (coreutils' version sort) behaves differently than
> other implementations in regards to minus character:
> 
>     $ printf "%s\n" abb ab-cd | sort -V
>     abb
>     ab-cd
> 
>     $ v1="abb"
>     $ v2="ab-cd"
>     $ dpkg --compare-versions "$v1" lt "$v2" && printf "$v1\n$v2\n" || printf "$v2\n$v1\n"
>     ab-cd
>     abb
> 
> If I understand correctly,
> The reason is that in Debian's version comparison algorithm [1], the minus
> character has a special meaning: it separates the "upstream version"
> part from the "debian revision" part.

Note that I'm not using "ls -v" to sort version numbers, just
filenames (which can contain integers in decimal notation).

-- 
Vincent Lefèvre <vincent <at> vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




This bug report was last modified 5 years and 352 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.