Package: coreutils Version: 8.21-1.1 Severity: normal Hi,
if I read this correctly: http://sources.debian.net/src/coreutils/8.21-1.2/src/sort.c#L2553 then sort uses this function (filevercmp) to sort version numbers with --version-sort: http://sources.debian.net/src/coreutils/8.21-1.2/lib/filevercmp.c?hl=73#L125 a comment in that file claims: 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 consider the following shell function as presented in [1] version_lt () { newest=$( ( echo "$1"; echo "$2" ) | sort -V | tail -n1) [ "$1" != "$newest" ] } [1] http://www.df7cb.de/blog/2014/Comparing_Version_Numbers_in_Shell.html Here an example for when `sort -V` does the wrong thing: $ dpkg --compare-versions 0.04-1-5 "<" 0.4-3 && echo yes || echo no no $ version_lt 0.04-1-5 0.4-3 && echo yes || echo no yes here another: $ dpkg --compare-versions 00004-1 "<" 1:3.8.3-7 && echo yes || echo no yes $ version_lt 00004-1 1:3.8.3-7 && echo yes || echo no no And here some more version combinations for which this is done wrongly: 0.04-1-5 0.4-3 0.1+20080921-2 0.1-1+b8 0.1+dfsg-4 000.001-4 0.1.0+20071012-1.2 0.1.0-1.1 0.3.0+20091229-1 0.3.0-7.2 0.6.0+git20130305-5 0.6.0-5+b1 0:2009.10.04-1 1.0pre11-1 0:2009.10.04-1 1.240-1 0:2009.10.04-1 1.7.2.4-4.1 0:2009.10.04-1 2.3-12 0:2009.10.04-1 8.0.184.15484+dfsg-2 1.0+dfsg-1 1.00-6 If you want to generate more test cases, consider the code for testing sort at https://github.com/josch/debversioncomp thanks! cheers, josch -- System Information: Debian Release: jessie/sid APT prefers testing APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 3.14-1-amd64 (SMP w/4 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages coreutils depends on: ii libacl1 2.2.52-1 ii libattr1 1:2.4.47-1 ii libc6 2.18-5 ii libselinux1 2.2.2-1 coreutils recommends no packages. coreutils suggests no packages. -- no debconf information -- debsums errors found: sh: 1: /usr/sbin/dpkg-divert: not found -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org