GNU bug report logs -
#35939
version sort is incorrect with hyphen-minus
Previous Next
Full log
Message #17 received at submit <at> debbugs.gnu.org (full text, mbox):
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.