From unknown Fri Sep 05 22:44:29 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#14226 <14226@debbugs.gnu.org> To: bug#14226 <14226@debbugs.gnu.org> Subject: Status: Sort -c takes in account fields that were outside sorting scope Reply-To: bug#14226 <14226@debbugs.gnu.org> Date: Sat, 06 Sep 2025 05:44:29 +0000 retitle 14226 Sort -c takes in account fields that were outside sorting sco= pe reassign 14226 coreutils submitter 14226 Camion SPAM severity 14226 normal tag 14226 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 18 13:10:54 2013 Received: (at submit) by debbugs.gnu.org; 18 Apr 2013 17:10:55 +0000 Received: from localhost ([127.0.0.1]:58831 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1USsMH-0008K5-Jb for submit@debbugs.gnu.org; Thu, 18 Apr 2013 13:10:54 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48795) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1USqSe-0003zy-Kk for submit@debbugs.gnu.org; Thu, 18 Apr 2013 11:09:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USqOF-0004Le-5L for submit@debbugs.gnu.org; Thu, 18 Apr 2013 11:04:51 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:50413) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USqOF-0004LK-2l for submit@debbugs.gnu.org; Thu, 18 Apr 2013 11:04:47 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USqOA-00060f-Ki for bug-coreutils@gnu.org; Thu, 18 Apr 2013 11:04:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USqO7-00048e-Jm for bug-coreutils@gnu.org; Thu, 18 Apr 2013 11:04:42 -0400 Received: from nm2-vm0.bullet.mail.ird.yahoo.com ([77.238.189.199]:42593) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1USqO7-00048N-59 for bug-coreutils@gnu.org; Thu, 18 Apr 2013 11:04:39 -0400 Received: from [77.238.189.57] by nm2.bullet.mail.ird.yahoo.com with NNFMP; 18 Apr 2013 15:04:37 -0000 Received: from [212.82.98.94] by tm10.bullet.mail.ird.yahoo.com with NNFMP; 18 Apr 2013 15:04:37 -0000 Received: from [127.0.0.1] by omp1031.mail.ir2.yahoo.com with NNFMP; 18 Apr 2013 15:04:37 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 368501.12713.bm@omp1031.mail.ir2.yahoo.com Received: (qmail 32451 invoked by uid 60001); 18 Apr 2013 15:04:37 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.fr; s=s1024; t=1366297477; bh=0ZsH/LljZB9Nfxh/TdNS9azh+mcrT1PQVOXuKiqVW6U=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=Wlg0miKFdwkkHeSv+/HuXhrhfGUPJ9iV9IMtl0E5vf/a3WZNp74qN4TkLOXLFOWK7Gl65zS1qbWR6dsu0uZGfUAh1AZJmAgOt1CPvW/PT9E2lQizbSzSCKgdZi0KJ2bmbI7E2pRvPOA1jPmjkQGYHKsXHDecBaQkFPrmA54kBQ8= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.fr; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=TOPsaJ0/NswS12YUvbz194S0QQnGLCzAH8VFFxC2bC0WW9/FbyIVNHZgGkz1pX6ggkxT311Wg53h5WmyEwSSUaazMb6BxLY1kLSL+8a5WPFBZgMiTXY20X8+rEiX7MP8ergDqY9FoXh6oJWsEuenv+cBcFuT4Ye8ExFyilpL2d8=; X-YMail-OSG: H5tcDh8VM1nzC7.7eM7dIumzfXi6rGdB2kfsd6waThHxzeq 5bsb2N88RMoD7GaqhhPwQ3f.kRXdR8U2iVSRcIaqWYIRmFUeGjApTOn5kXH. lqYNwrMhZBRPbVXI0Ux5tFp5vXLcgp5T7U8L6X8ue7QRSnjbedkxWBF4.oNc fQL3Iv.zmZy3v1zglxZKTtn.aSAr5Axv_g8BeTf9WLBmQKhL7Ga4xruaicEx hl8Wdd.AsNcze70riNxpJXqk5kKRIHafdJIKwKDTXbDAFDg6HzOs7eKIaFGj HEoiAi65l1uHBkqCLUi9dyz7RnUuLkS0nbwrBEtWz_sSpo52b8uw5JvH.ZOy 47ZZ4MnXcEpvW0we0RNJBuaMZTgA60b04YIZC2XUzd8Uz85MwjHbooaYHyXg kOpiQXubpMZ9.OrT4iC1AWktawRUGTZPMJ80aisGItsyZj8nHsk3g_T6sWuL PFIiYrQLQoEGVM0CIUiS8iikpXkiVT9TevPFTJW.LMvc6Uw-- Received: from [213.189.160.119] by web133002.mail.ir2.yahoo.com via HTTP; Thu, 18 Apr 2013 16:04:37 BST X-Rocket-MIMEInfo: 002.001, VGhlIGZvbGxvd2luZyBjb21tYW5kcyByZXBvcnQgYW4gZXJyb3Igb24gZXF1YWxzIGxpbmVzIGJlY2F1c2UgZmllbGQgb3V0c2lkZSBzb3J0aW5nIHNjb3BlIHdlcmUgbm90IHNvcnRlZAoKJMKgY2F0IDw8Jy4nIHwKPiBBQUEgQUFBCj4gQkJCIEJCQgo.IFpaWiBDQ0MKPiBEREQgRERECj4gQkJDIEVFRQo.IEJCRCBFRUUKPiBCQkMgRUVFCj4gQkJFIEVFRQo.IENDQyBGRkYKPiBEREQgR0dHCj4gRUVFIEhISAo.IC4KPiBMQU5HPUMgc29ydCAtayAyLDIgLWMKc29ydDogLTo3OiBkaXNvcmRlcjogQkJDIEVFRQoBMAEBAQE- X-Mailer: YahooMailWebService/0.8.140.532 Message-ID: <1366297477.29023.YahooMailNeo@web133002.mail.ir2.yahoo.com> Date: Thu, 18 Apr 2013 16:04:37 +0100 (BST) From: Camion SPAM Subject: Sort -c takes in account fields that were outside sorting scope To: "bug-coreutils@gnu.org" MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="-1350297820-2127965916-1366297477=:29023" X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 18 Apr 2013 13:10:51 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: Camion SPAM List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) ---1350297820-2127965916-1366297477=:29023 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable The following commands report an error on equals lines because field outsid= e sorting scope were not sorted=0A=0A$=A0cat <<'.' |=0A> AAA AAA=0A> BBB BB= B=0A> ZZZ CCC=0A> DDD DDD=0A> BBC EEE=0A> BBD EEE=0A> BBC EEE=0A> BBE EEE= =0A> CCC FFF=0A> DDD GGG=0A> EEE HHH=0A> .=0A> LANG=3DC sort -k 2,2 -c=0Aso= rt: -:7: disorder: BBC EEE=0A ---1350297820-2127965916-1366297477=:29023 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
The = following commands report an error on equals lines because field outside so= rting scope were not sorted

$ = cat <<'.' |
> AAA AAA
> BBB BBB
> ZZZ C= CC
> DDD DDD
> BBC EEE
> BBD EEE=
> BB= C EEE
> BBE EEE
> CCC FFF
> DDD GGG
> EEE HHH
> .
> LANG=3DC sort -k 2,2 -c
so= rt: -:7: disorder: BBC EEE

---1350297820-2127965916-1366297477=:29023-- From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 18 15:58:04 2013 Received: (at control) by debbugs.gnu.org; 18 Apr 2013 19:58:04 +0000 Received: from localhost ([127.0.0.1]:59110 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1USuy2-0006PT-Mi for submit@debbugs.gnu.org; Thu, 18 Apr 2013 15:58:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36277) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1USuxx-0006Or-H5; Thu, 18 Apr 2013 15:57:59 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3IJrPSZ013323 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 18 Apr 2013 15:53:25 -0400 Received: from [10.3.113.85] (ovpn-113-85.phx2.redhat.com [10.3.113.85]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r3IJrOp0008157; Thu, 18 Apr 2013 15:53:25 -0400 Message-ID: <51704F34.4020006@redhat.com> Date: Thu, 18 Apr 2013 13:53:24 -0600 From: Eric Blake Organization: Red Hat, Inc. User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130402 Thunderbird/17.0.5 MIME-Version: 1.0 To: Camion SPAM Subject: Re: bug#14226: Sort -c takes in account fields that were outside sorting scope References: <1366297477.29023.YahooMailNeo@web133002.mail.ir2.yahoo.com> In-Reply-To: <1366297477.29023.YahooMailNeo@web133002.mail.ir2.yahoo.com> X-Enigmail-Version: 1.5.1 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2IITPWTQHLLGQCWAMBBCK" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-Spam-Score: -7.6 (-------) X-Debbugs-Envelope-To: control Cc: 14226-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -7.6 (-------) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2IITPWTQHLLGQCWAMBBCK Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable tag 14226 notabug thanks On 04/18/2013 09:04 AM, Camion SPAM wrote: > The following commands report an error on equals lines because field ou= tside sorting scope were not sorted How refreshing to get a non-FAQ report on sort - you made me actually do some research! The fact that you used LANG=3DC to pin the locale is also= nice (most people aren't aware that most reported non-bugs in sort are due to locale issues). However, I still think sort is doing the right thing. >=20 > $ cat <<'.' | >> AAA AAA >> BBB BBB >> ZZZ CCC >> DDD DDD >> BBC EEE >> BBD EEE >> BBC EEE >> BBE EEE >> CCC FFF >> DDD GGG >> EEE HHH >> . >> LANG=3DC sort -k 2,2 -c > sort: -:7: disorder: BBC EEE POSIX says: "Except when the -u option is specified, lines that otherwise compare equal shall be ordered as if none of the options -d, -f, -i, -n, or -k were present (but with -r still in effect, if it was specified) and with all bytes in the lines significant to the comparison." http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sort.html In your example, you did not use -u, and the key you specified was duplicated between two rows, so POSIX requires sort to break the tie by comparing the entire line, and the entire line is indeed different. For comparison purposes, I checked out /usr/bin/sort on Solaris 10; it has the same behavior of declaring your input unsorted. /usr/xpg4/bin/sort on the same machine is not POSIX compliant, in that it lacks -C, and treats -c like the POSIX -C; but it also had non-zero exit status on your sample. If you don't like the POSIX behavior of a mandated entire line as a sort key of final resort, then you should use the GNU extension of -s, I tested that 'LC_ALL=3DC sort -k2,2 -c -s' has no problems with your example. To see the difference of using or not using the entire line as the final sort key, replace -c by --debug, both with and without -s (you can't use -c and --debug at the same time, unfortunately). However, remember that not all sort implementations have -s, so there is no standard way to get the behavior you are after. I'm closing this as not a bug, although you may continue to add comments or questions to this topic. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2IITPWTQHLLGQCWAMBBCK Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRcE80AAoJEKeha0olJ0NqJv8H/iZPICiP1DkQX4FM7orN92zl WFGBVKQe3h+md3A36q+8AoVb1VOr5gWVcls5dCQXy+rcfiuzUON0b2yheqIZbina rBOuLzZViIuBnG3+lxT0eq+VLPscFtP7YVHhmXe20ESzyJiXZO28lRVCKGoyi9By bzeV9ORVkkwEyb4aYhc4yV3FXt0rgemso4Clm61/ppJX6nxvSxIScXW9/hhPb1T5 WnuWdsf7vwDVveNcFw2w5OunyAFht2f4seoaCfgMW8yt5WkMZ2INND1kaoA1oR3l UatsIsN21sKtiTFkt5rcWHPO2rnXAX93cvZ6oxYyVNbhNRvNvp9DoOqpRLsyb9A= =zi7f -----END PGP SIGNATURE----- ------enig2IITPWTQHLLGQCWAMBBCK-- From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 19 21:00:55 2013 Received: (at 14226-done) by debbugs.gnu.org; 20 Apr 2013 01:00:55 +0000 Received: from localhost ([127.0.0.1]:60936 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UTMAg-0004UZ-Js for submit@debbugs.gnu.org; Fri, 19 Apr 2013 21:00:55 -0400 Received: from nm11-vm0.bullet.mail.ird.yahoo.com ([77.238.189.218]:25547) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1UTMAd-0004UN-ON for 14226-done@debbugs.gnu.org; Fri, 19 Apr 2013 21:00:54 -0400 Received: from [77.238.189.230] by nm11.bullet.mail.ird.yahoo.com with NNFMP; 20 Apr 2013 00:56:13 -0000 Received: from [212.82.108.132] by tm11.bullet.mail.ird.yahoo.com with NNFMP; 20 Apr 2013 00:56:13 -0000 Received: from [127.0.0.1] by omp1037.mail.ird.yahoo.com with NNFMP; 20 Apr 2013 00:56:13 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 656279.92067.bm@omp1037.mail.ird.yahoo.com Received: (qmail 65117 invoked by uid 60001); 20 Apr 2013 00:56:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.fr; s=s1024; t=1366419373; bh=CMnjdAh5E9N0I12AIg8MxG//2TYvm/OT7MpnHExAtv0=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type; b=xx4jFpw8G9URuVB3mJs8taqaoFKGtTngqsEO5DDb2WX2VcbqyqTvGXZ0KjCpcoutyBK2+xRoZtNrnqUFvQmtQPFX5jyoqPp1i+dzkPRWhRkNYRCvGBjmGQWD2HeGBeqskfUl1pbbWdGXHX/usEgkMN4cnSMLjRBMEyDSzSiGYAc= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.fr; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type; b=wdgDxDSOeUYrbu8EL+Y0abFyY1hH4gmDf40JCnw6KtznCDCMavu5IRoKi7JurAv9c38ZB7cHqqrcqTP5d8NqkdF2VtMu4yaaJYzDEEa/VIwhkIfdNiaDZfHFNKkjj1/VA5xK9+K5X3tM6NX49y30O1YeXXg5K7zg3YHHQSEGr54=; X-YMail-OSG: ZhSUKOoVM1kD4AkKKztht0o8TEq8dt9Kfs4Um5zG0vk_A_8 NkKPFjX347VtKZceQPQPigvreJ.MI_dX.9ydlpFt7vyC6UrJA2PeRMVzDxY2 aEakS3xgO1XArcdGc84LKJqGXlatqQ9TWpKZ4aqigWXNa55.qdJ486JGRdgb Rhc1W3Es9nX_fdGmvCJhgBadzFLFq8s5tbCJWO5ASCsZawOREm5bLu9Z_B7v BK.WHQBxiODiafCo29_8pe26HD4qMaD2rmHco9WAsrcCVbfbRLCEY7TAVeQg zc2EPkYyegRmRPAbYnwqfEEykz6tNV1_a9etYwBCxgbUZSJseiDFEtaJKNci erVaW20Zp.wesT7cynYL8ORWHDLC0RKeoaDuEDCQtuZu.jCEcdzoEZChEFm9 GxNw29oFJoE1mF0j6ixPeHitbfYRK7ArFvh_hDpXlQ7NDx0AP_ez.OIqcT00 soGdOqhW84C8Vrsun9FmHB6ff3vu0i8rRTX7vWGZfbXcBCSMx2LRW_ERUk1k 9240A0XBJfQdQ7La3vWk7L_8iAXE7nrmu0zmp1VS84ghcki1jXtV8SnFblAB HwjiYBmBmrhSeSr_X9scqTtxF9uSmj5oJZcGJsQXwRmVXAaURcVtu5x4DeIf 6H5xlLkQvNLmoW4NqzAx9mwq57kDpWf_LFJOniog33BLa_r1LTgprPO9xJIM - Received: from [213.189.160.119] by web133002.mail.ir2.yahoo.com via HTTP; Sat, 20 Apr 2013 01:56:13 BST X-Rocket-MIMEInfo: 002.001, V2VsbCwgSSdtIHNhdGlzZmllZCB3aXRoIHlvdXIgc3VnZ2VzdGlvbiBvZiBhZGRpbmcgLXMuwqAKSSB3b3VsZCBqdXN0IGFkZCB0aGF0IHRoaXMgbWlnaHQgYmUgc29tZXRoaW5nIHRoYXQgc2hvdWxkIGJlIGFkZGVkIHRvIHRoZSBtYW4gcGFnZS4KCgpfX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fXwogRGXCoDogRXJpYyBCbGFrZSA8ZWJsYWtlQHJlZGhhdC5jb20.CsOAwqA6IENhbWlvbiBTUEFNIDxjYW1pb25fc3BhbS1nbnVidWdzQHlhaG9vLmZyPiAKQ2PCoDogMTQyMjYtZG9uZUBkZWJidWdzLmcBMAEBAQE- X-Mailer: YahooMailWebService/0.8.141.536 References: <1366297477.29023.YahooMailNeo@web133002.mail.ir2.yahoo.com> <51704F34.4020006@redhat.com> Message-ID: <1366419373.64992.YahooMailNeo@web133002.mail.ir2.yahoo.com> Date: Sat, 20 Apr 2013 01:56:13 +0100 (BST) From: Camion SPAM Subject: Re: bug#14226: Sort -c takes in account fields that were outside sorting scope To: Eric Blake In-Reply-To: <51704F34.4020006@redhat.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="-1350297820-1097287955-1366419373=:64992" X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 14226-done Cc: "14226-done@debbugs.gnu.org" <14226-done@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: Camion SPAM List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) ---1350297820-1097287955-1366419373=:64992 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Well, I'm satisfied with your suggestion of adding -s.=A0=0AI would just ad= d that this might be something that should be added to the man page.=0A=0A= =0A________________________________=0A De=A0: Eric Blake =0A=C0=A0: Camion SPAM =0ACc=A0: 14226-done= @debbugs.gnu.org =0AEnvoy=E9 le : Jeudi 18 avril 2013 21h53=0AObjet=A0: Re:= bug#14226: Sort -c takes in account fields that were outside sorting scope= =0A =0A=0Atag 14226 notabug=0Athanks=0A=0AOn 04/18/2013 09:04 AM, Camion SP= AM wrote:=0A> The following commands report an error on equals lines becaus= e field outside sorting scope were not sorted=0A=0AHow refreshing to get a = non-FAQ report on sort - you made me actually do=0Asome research!=A0 The fa= ct that you used LANG=3DC to pin the locale is also=0Anice (most people are= n't aware that most reported non-bugs in sort are=0Adue to locale issues).= =A0 However, I still think sort is doing the right=0Athing.=0A=0A> =0A> $ c= at <<'.' |=0A>> AAA AAA=0A>> BBB BBB=0A>> ZZZ CCC=0A>> DDD DDD=0A>> BBC EEE= =0A>> BBD EEE=0A>> BBC EEE=0A>> BBE EEE=0A>> CCC FFF=0A>> DDD GGG=0A>> EEE = HHH=0A>> .=0A>> LANG=3DC sort -k 2,2 -c=0A> sort: -:7: disorder: BBC EEE=0A= =0APOSIX says:=0A"Except when the -u option is specified, lines that otherw= ise compare=0Aequal shall be ordered as if none of the options -d, -f, -i, = -n, or -k=0Awere present (but with -r still in effect, if it was specified)= and with=0Aall bytes in the lines significant to the comparison."=0Ahttp:/= /pubs.opengroup.org/onlinepubs/9699919799/utilities/sort.html=0A=0AIn your = example, you did not use -u, and the key you specified was=0Aduplicated bet= ween two rows, so POSIX requires sort to break the tie by=0Acomparing the e= ntire line, and the entire line is indeed different.=0A=0AFor comparison pu= rposes, I checked out /usr/bin/sort on Solaris 10; it=0Ahas the same behavi= or of declaring your input unsorted.=0A/usr/xpg4/bin/sort on the same machi= ne is not POSIX compliant, in that=0Ait lacks -C, and treats -c like the PO= SIX -C; but it also had non-zero=0Aexit status on your sample.=0A=0AIf you = don't like the POSIX behavior of a mandated entire line as a sort=0Akey of = final resort, then you should use the GNU extension of -s, I=0Atested that = 'LC_ALL=3DC sort -k2,2 -c -s' has no problems with your=0Aexample.=A0 To se= e the difference of using or not using the entire line as=0Athe final sort = key, replace -c by --debug, both with and without -s (you=0Acan't use -c an= d --debug at the same time, unfortunately).=A0 However,=0Aremember that not= all sort implementations have -s, so there is no=0Astandard way to get the= behavior you are after.=0A=0AI'm closing this as not a bug, although you m= ay continue to add comments=0Aor questions to this topic.=0A=0A-- =0AEric B= lake=A0 eblake redhat com=A0 =A0 +1-919-301-3266=0ALibvirt virtualization = library http://libvirt.org ---1350297820-1097287955-1366419373=:64992 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Well, I'm satisfied w= ith your suggestion of adding -s. 
I would just add tha= t this might be something that should be added to the man page.


De :<= /span> Eric Blake <eblake@redhat.com>
=C0 : Camion SPAM <camion_spam-gnubugs@ya= hoo.fr>
Cc : 14226-done@debbugs.gnu.org
Envo= y=E9 le : Jeudi 18 avril 2013 21h53
Objet : Re: bug#14226: Sort -c takes in accou= nt fields that were outside sorting scope

tag 14226 notabug
thanks

On 04/18/2013 09:04= AM, Camion SPAM wrote:
> The following commands report an error on e= quals lines because field outside sorting scope were not sorted

How = refreshing to get a non-FAQ report on sort - you made me actually do
som= e research!  The fact that you used LANG=3DC to pin the locale is also=
nice (most people aren't aware that most reported non-bugs in sort are<= br>due to locale issues).  However, I still think sort is doing the ri= ght
thing.

>
> $ cat <<'.' |
>> AAA AAA<= br>>> BBB BBB
>> ZZZ CCC
>> DDD DDD
>> BBC EEE
>> BBD EEE
>> BBC EEE
>> BBE EEE
>>= ; CCC FFF
>> DDD GGG
>> EEE HHH
>> .
>>= LANG=3DC sort -k 2,2 -c
> sort: -:7: disorder: BBC EEE

POSIX = says:
"Except when the -u option is specified, lines that otherwise comp= are
equal shall be ordered as if none of the options -d, -f, -i, -n, or = -k
were present (but with -r still in effect, if it was specified) and w= ith
all bytes in the lines significant to the comparison."
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sort= .html

In your example, you did not use -u, and the key you speci= fied was
duplicated between two rows, so POSIX requires sort to break th= e tie by
comparing the entire line, and the entire line is indeed differ= ent.

For comparison purposes, I checked out /usr/bin/sort on Solaris 10; it
has the same behavior of declaring your input unsorted.<= br>/usr/xpg4/bin/sort on the same machine is not POSIX compliant, in thatit lacks -C, and treats -c like the POSIX -C; but it also had non-zeroexit status on your sample.

If you don't like the POSIX behavior of= a mandated entire line as a sort
key of final resort, then you should u= se the GNU extension of -s, I
tested that 'LC_ALL=3DC sort -k2,2 -c -s' = has no problems with your
example.  To see the difference of using = or not using the entire line as
the final sort key, replace -c by --debu= g, both with and without -s (you
can't use -c and --debug at the same ti= me, unfortunately).  However,
remember that not all sort implementa= tions have -s, so there is no
standard way to get the behavior you are a= fter.

I'm closing this as not a bug, although you may continue to ad= d comments
or questions to this topic.

--
Eric Blake  eblake redhat com    +1-919-301-3266
Libvirt vir= tualization library http:= //libvirt.org



---1350297820-1097287955-1366419373=:64992-- From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 20 11:59:14 2013 Received: (at 14226-done) by debbugs.gnu.org; 20 Apr 2013 15:59:14 +0000 Received: from localhost ([127.0.0.1]:33682 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UTaC2-0001Mb-5J for submit@debbugs.gnu.org; Sat, 20 Apr 2013 11:59:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52247) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UTaBy-0001MP-Mb for 14226-done@debbugs.gnu.org; Sat, 20 Apr 2013 11:59:13 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3KFsSVw000626 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 20 Apr 2013 11:54:29 -0400 Received: from [10.3.113.85] (ovpn-113-85.phx2.redhat.com [10.3.113.85]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r3KFsQoc007385; Sat, 20 Apr 2013 11:54:28 -0400 Message-ID: <5172BA32.2070709@redhat.com> Date: Sat, 20 Apr 2013 09:54:26 -0600 From: Eric Blake Organization: Red Hat, Inc. User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130402 Thunderbird/17.0.5 MIME-Version: 1.0 To: Camion SPAM Subject: Re: bug#14226: Sort -c takes in account fields that were outside sorting scope References: <1366297477.29023.YahooMailNeo@web133002.mail.ir2.yahoo.com> <51704F34.4020006@redhat.com> <1366419373.64992.YahooMailNeo@web133002.mail.ir2.yahoo.com> In-Reply-To: <1366419373.64992.YahooMailNeo@web133002.mail.ir2.yahoo.com> X-Enigmail-Version: 1.5.1 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2XUGHEHSACSBHPIJQHLNT" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-Spam-Score: -7.6 (-------) X-Debbugs-Envelope-To: 14226-done Cc: "14226-done@debbugs.gnu.org" <14226-done@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -7.6 (-------) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2XUGHEHSACSBHPIJQHLNT Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 04/19/2013 06:56 PM, Camion SPAM wrote: > Well, I'm satisfied with your suggestion of adding -s.=20 > I would just add that this might be something that should be added to t= he man page. The man page is generated from 'sort --help', and there, we are trying to favor brevity. But it might indeed be worth adding to the 'info sort' page. I read that page, and notice that while '-c' and '-C' are mentioned first, details about '-k' and '-s' are several screenfuls away, so it is not obvious that those two options can affect the behavior of -c. You could help by reading that page, and finding the spot(s) where adding a sentence would have helped you; if you could propose the location and wording to add, then we can work with that to turn it into a formal patch. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2XUGHEHSACSBHPIJQHLNT Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRcroyAAoJEKeha0olJ0NqqSIIAI+QvrefT5pziNsHzR0IqfW6 Bhf1T2t5MCtq7anQAjGWUW87cN4toGtigFl68hcbtNJQwcz0UgEin2RNKR6JLAx3 Hr7Fj77zdFZ/vwB8IuK2qkzf/Mb9BIEJJ7Pm3s4ImiY/OCHgGSHspk/HCp6xrIE0 PgcX1m4ShjpsUuqoZ/PoojW/ssN0mosPBUAA1vpSpkSw8vZkbSjo/ZqR682pFDh3 QaSC1RkDWEvOw3Oue/+6+wL9Zj/IwqTZg85ceMAVCmNM7/tarw+0unjsXq+NyAuG L9RoUkqXPvUDpY1EVfPtTzZuruoLe9FsIT6EsIh+ZkWA59sgPbIHTkl1MltMnDk= =fAEi -----END PGP SIGNATURE----- ------enig2XUGHEHSACSBHPIJQHLNT-- From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 20 21:04:52 2013 Received: (at 14226-done) by debbugs.gnu.org; 21 Apr 2013 01:04:52 +0000 Received: from localhost ([127.0.0.1]:34241 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UTii0-0000Kd-O6 for submit@debbugs.gnu.org; Sat, 20 Apr 2013 21:04:50 -0400 Received: from nm12-vm0.bullet.mail.ird.yahoo.com ([77.238.189.196]:35108) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1UTiht-0000KM-OU for 14226-done@debbugs.gnu.org; Sat, 20 Apr 2013 21:04:43 -0400 Received: from [77.238.189.231] by nm12.bullet.mail.ird.yahoo.com with NNFMP; 21 Apr 2013 00:59:57 -0000 Received: from [212.82.108.237] by tm12.bullet.mail.ird.yahoo.com with NNFMP; 21 Apr 2013 00:59:57 -0000 Received: from [127.0.0.1] by omp1002.mail.ird.yahoo.com with NNFMP; 21 Apr 2013 00:59:57 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 383769.75770.bm@omp1002.mail.ird.yahoo.com Received: (qmail 49634 invoked by uid 60001); 21 Apr 2013 00:59:57 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.fr; s=s1024; t=1366505997; bh=ZROsynKPLGZq9R8Ca7aMb/kjrT2OsMYQsCPlNi27QbA=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type; b=1teoSLjk6IqA3ni3Wr8fP+GJMjpJkrKLfFyYi+VlWPEDOBHWLutTGFcMT38YbwZFW68PmZy686Cc0ncvdpiv2gJuXIX6jr1oUmWJCpcUEbrGHa+yKFcf0pkRujxy3RF0KKHw7wL4zMeyBYW5E1ksdFSH/1Z2p7kYuNqXcsmIVXM= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.fr; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type; b=mKT6m1qEmAr0pLOh++WFss2vwqzRJgOn1njZqlauCs+u5chadDlFNX5pNMtkZR6PJNVA+w3C3lKqAYcGGS/q6reZq0R9wTwgFr105rEoNIpHp6MUVCWdrygj8fh828f2zxvBTtP5XELAieOqdj3CqIbBOuYJ4X0Q6n2c5+6zwSM=; X-YMail-OSG: anHpyG0VM1lO3yF0DC508jZupOVROGfEFY5uQ.Je2UrFUfk JZ7yMdkPfsb2TYBoxZxIpQgtkbQNE82CIAu4aVnOsrCrq6DDDFEik.MqwERq J7X_TOf2jTE29ZoKl.waeoCy4lDy9Z0jHJQlfKIGPlSuz1vulPBaUunCdAtu X_Dz9JZVIC.dvBsbCFYgFqu7nHOWve0mnpP_PgHthq6.HxrUF5cWRTaOBfop 25ScLNT4IVifp18Ste42nC_MoogZ9Q_lo3JKUcn0PwWWRjr9WEUHrty9qlic 7YUUWSAYUiOAgOiPimDVvYTDFzDzgiN5INk5mpCsoo0B1SgOBHgdBTGqkBHX i4XoY1bsID867AA1pptjZzvem6gSli7EwoGXd4zpA22LY3ffSQ3W27XCFLur geBy_097XjWOYjKFy0jbKI8XnGST5VGGsjtk6rqGuGoocATk5pnP4gaAR3UB lRZJ0HRKdIizL8as_b2b.ENgl1esn.OiwbrVvJ3MoyEfdtw4aEiNodVeFpT3 f8jKhxAolHeEb36_.bd97y0yKGnTYwb4iMyLO8evqgbvsC1jHH5_1SI130xx D1A-- Received: from [213.189.160.119] by web133002.mail.ir2.yahoo.com via HTTP; Sun, 21 Apr 2013 01:59:57 BST X-Rocket-MIMEInfo: 002.001, VGhlbiwgSSBzdWdnZXN0IGFkZGluZyBhZnRlciAtYyA6wqAKwqAgLWMsIC0tY2hlY2ssIC0tY2hlY2s9ZGlhZ25vc2UtZmlyc3QgwqBjaGVjayBmb3Igc29ydGVkIGlucHV0OyBkbyBub3Qgc29ydAoKPj4gTm90ZSB0aGF0LCB3aGVuIHNlbGVjdGluZyBmaWVsZHMgd2l0aCAtayB3aGlsZcKgdXNpbmcgdGhlIC1jIHN3aXRjaCwgdXNlciBzaG91bGQgcHJvYmFibHkgYWxzbyBkaXNhYmxlIHRoZSBsYXN0LXJlc29ydCBjb21wYXJpc29uIHdpdGggLXMgdG8gb2J0YWluIHRoZSBleHBlY3RlZCByZXN1bHQuCgphZnQBMAEBAQE- X-Mailer: YahooMailWebService/0.8.141.536 References: <1366297477.29023.YahooMailNeo@web133002.mail.ir2.yahoo.com> <51704F34.4020006@redhat.com> <1366419373.64992.YahooMailNeo@web133002.mail.ir2.yahoo.com> <5172BA32.2070709@redhat.com> Message-ID: <1366505997.46205.YahooMailNeo@web133002.mail.ir2.yahoo.com> Date: Sun, 21 Apr 2013 01:59:57 +0100 (BST) From: Camion SPAM Subject: Re: bug#14226: Sort -c takes in account fields that were outside sorting scope To: Eric Blake In-Reply-To: <5172BA32.2070709@redhat.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="-1350297820-1807443978-1366505997=:46205" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 14226-done Cc: "14226-done@debbugs.gnu.org" <14226-done@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: Camion SPAM List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) ---1350297820-1807443978-1366505997=:46205 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Then, I suggest adding after -c :=A0=0A=A0 -c, --check, --check=3Ddiagnose-= first =A0check for sorted input; do not sort=0A=0A>> Note that, when select= ing fields with -k while=A0using the -c switch, user should probably also d= isable the last-resort comparison with -s to obtain the expected result.=0A= =0Aafter -k :=A0=0A=0A=A0 -k, --key=3DPOS1[,POS2] =A0 =A0 start a key at PO= S1 (origin 1), end it at POS2=A0(default end of line)=A0=0A>> By default, i= f two lines are considered equivalent regarding the key specification, sort= will try to resolve the equivalence by comparing the whole lines. This is = called=A0the "last-resort comparison" (and may be disabled with -s)=0A=0Aan= d after -s :=0A=A0 -s, --stable =A0 =A0 =A0 =A0 =A0 =A0 =A0stabilize sort b= y disabling last-resort comparison=0A=0A>> (See -k)=0A=0A=0A_______________= _________________=0A De=A0: Eric Blake =0A=C0=A0: Camion= SPAM =0ACc=A0: "14226-done@debbugs.gnu.org"= <14226-done@debbugs.gnu.org> =0AEnvoy=E9 le : Samedi 20 avril 2013 17h54= =0AObjet=A0: Re: bug#14226: Sort -c takes in account fields that were outsi= de sorting scope=0A =0A=0AOn 04/19/2013 06:56 PM, Camion SPAM wrote:=0A> We= ll, I'm satisfied with your suggestion of adding -s. =0A> I would just add = that this might be something that should be added to the man page.=0A=0AThe= man page is generated from 'sort --help', and there, we are trying=0Ato fa= vor brevity.=A0 But it might indeed be worth adding to the 'info=0Asort' pa= ge.=A0 I read that page, and notice that while '-c' and '-C' are=0Amentione= d first, details about '-k' and '-s' are several screenfuls=0Aaway, so it i= s not obvious that those two options can affect the=0Abehavior of -c.=A0 Yo= u could help by reading that page, and finding the=0Aspot(s) where adding a= sentence would have helped you; if you could=0Apropose the location and wo= rding to add, then we can work with that to=0Aturn it into a formal patch.= =0A=0A-- =0AEric Blake=A0 eblake redhat com=A0 =A0 +1-919-301-3266=0ALibvi= rt virtualization library http://libvirt.org ---1350297820-1807443978-1366505997=:46205 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Then, I suggest adding after -c : 
  -c, --check, --check=3Ddiagnose-first  ch= eck for sorted input; do not sort
>> Note that, when selecting fields with -k while using the -c switch, user should prob= ably also disable the last-resort comparison with -s to obtain the expected result.<= /span>

after -k : 
=
  -k, --key=3DPOS1[,POS2] &= nbsp;   start a key at POS1 (origin 1), end it at POS2 (default end of line) 
>> By default, if two lines are considered e= quivalent regarding the key specification, sort will try to resolve the equivalence = by comparing the whole lines. This is called the "last-resort c= omparison" (and may be disabled with -s)

and after -s :
  -s, --stable     &nb= sp;        stabilize sort by disabling last-resort comp= arison
>> (See -k)

=
De : Eric Blake <eblake@redhat.com>
<= b>=C0 : Camion SPAM <= camion_spam-gnubugs@yahoo.fr>
= Cc : "14226-done@debbugs.gnu.org" <14226-done@debbugs.gn= u.org>
Envoy=E9 le : Samedi 20 avril 2013 17h54
Obj= et : Re: bug#14226: Sort -c takes in account fields that we= re outside sorting scope
=
On 04/19/2013 06:56 PM, Camion SPAM wrote:
> Well, I'm satisfied = with your suggestion of adding -s.
> I would just add that this might be some= thing that should be added to the man page.

The man page is generate= d from 'sort --help', and there, we are trying
to favor brevity.  B= ut it might indeed be worth adding to the 'info
sort' page.  I read= that page, and notice that while '-c' and '-C' are
mentioned first, det= ails about '-k' and '-s' are several screenfuls
away, so it is not obvio= us that those two options can affect the
behavior of -c.  You could= help by reading that page, and finding the
spot(s) where adding a sente= nce would have helped you; if you could
propose the location and wording= to add, then we can work with that to
turn it into a formal patch.
<= br>--
Eric Blake  eblake redhat com    +1-919-301-3266<= br>Libvirt virtualization library http://libvirt.org



=20
---1350297820-1807443978-1366505997=:46205-- From unknown Fri Sep 05 22:44:29 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 19 May 2013 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator