From owner-freebsd-i386@freebsd.org Fri Sep 30 18:58:28 2016 Return-Path: Delivered-To: freebsd-i386@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BFAB7C04953 for ; Fri, 30 Sep 2016 18:58:28 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 957FC9BB for ; Fri, 30 Sep 2016 18:58:28 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id u8UIwSWe046757 for ; Fri, 30 Sep 2016 18:58:28 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-i386@FreeBSD.org Subject: [Bug 213128] version sort (sort -V) order incorrect with non-alphanumeric characters Date: Fri, 30 Sep 2016 18:58:28 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 10.3-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: skh1002@hotmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter cc Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-i386@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: I386-specific issues for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Sep 2016 18:58:28 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D213128 Bug ID: 213128 Summary: version sort (sort -V) order incorrect with non-alphanumeric characters Product: Base System Version: 10.3-RELEASE Hardware: i386 OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: freebsd-bugs@FreeBSD.org Reporter: skh1002@hotmail.com CC: freebsd-i386@FreeBSD.org CC: freebsd-i386@FreeBSD.org On FreeBSD 10.3-RELEASE-p9 with /usr/bin/sort version 2.3-FreeBSD: Version-sorting produces incorrect order if non-alphanumeric characters are present in sorted lines. Prefix (name) parts of the sorted lines sharing the same starting characters are seemingly sorted in the reverse order. This is= an example from my package folder: $ ls /usr/ports/packages/All | sort -V =E2=80=A6 pkgconf-0.9.12_1.txz pkgconf-1.0.1.txz pkg-1.6.4_1.txz pkg-1.7.1.txz pkg-1.7.2.txz =E2=80=A6 To reproduce the behaviour, the following can be done. The next two commands produce identical and correct output: $ echo -e "aa\nab\nabcdefg\nabd\nabcde\nabc\nabcdef"|sort aa ab abc abcde abcdef abcdefg abd And $ echo -e "aa\nab\nabcdefg\nabd\nabcde\nabc\nabcdef"|sort -V aa ab abc abcde abcdef abcdefg abd However, the second of these two produces clearly incorrect sort order: $ echo -e "aa-\nab-\nabcdefg-\nabd-\nabcde-\nabc-\nabcdef-=E2=80=9C|sort aa- ab- abc- abcde- abcdef- abcdefg- abd- But $ echo -e "ab-\nabcdefg-\nabd-\nabcde-\nabc-\nabcdef-"|sort -V abcdefg- abcdef- abcde- abc- abd- ab- The same behaviour is observed when different non-alphanumeric characters a= re appended to the end of the sorted strings: echo -e "ab-\nabcdefg&\nabd#\nabcde@\nabc&\nabcdef_"|sort -V abcdefg& abcdef_ abcde@ abc& abd# ab- --=20 You are receiving this mail because: You are on the CC list for the bug.=