From unknown Fri Sep 05 15:37:08 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#21880 <21880@debbugs.gnu.org> To: bug#21880 <21880@debbugs.gnu.org> Subject: Status: Possible bug in sort --check --key Reply-To: bug#21880 <21880@debbugs.gnu.org> Date: Fri, 05 Sep 2025 22:37:08 +0000 retitle 21880 Possible bug in sort --check --key reassign 21880 coreutils submitter 21880 Alexander Kindyakov severity 21880 normal tag 21880 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 11 13:51:49 2015 Received: (at submit) by debbugs.gnu.org; 11 Nov 2015 18:51:49 +0000 Received: from localhost ([127.0.0.1]:33534 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZwaUm-0002oB-Ty for submit@debbugs.gnu.org; Wed, 11 Nov 2015 13:51:49 -0500 Received: from eggs.gnu.org ([208.118.235.92]:46508) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZwaTm-0002mP-W1 for submit@debbugs.gnu.org; Wed, 11 Nov 2015 13:50:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwaTh-00016w-9M for submit@debbugs.gnu.org; Wed, 11 Nov 2015 13:50:46 -0500 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, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:52505) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwaTh-00016r-3X for submit@debbugs.gnu.org; Wed, 11 Nov 2015 13:50:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwaTQ-0003wO-5i for bug-coreutils@gnu.org; Wed, 11 Nov 2015 13:50:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwaTK-000141-5y for bug-coreutils@gnu.org; Wed, 11 Nov 2015 13:50:24 -0500 Received: from mail-lf0-x236.google.com ([2a00:1450:4010:c07::236]:35954) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwaTJ-00013w-Uw for bug-coreutils@gnu.org; Wed, 11 Nov 2015 13:50:18 -0500 Received: by lfs39 with SMTP id 39so21273657lfs.3 for ; Wed, 11 Nov 2015 10:50:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:from:subject:message-id:date:user-agent:mime-version :content-type:content-transfer-encoding; bh=DIOoz1jHtFplFyTxBmiFZQAjbbEb1NqY0B2AN5DKRY0=; b=Z/kp69CEjBdeMEtedQ/SKct3pikM6X7vZAfroxvM5qN7DGpEHTY/7QOJFcleqAFoMK 0CvcEayBAkeX6N72YKO9vnK2CpuCxMaOdRjgiHcmgVeodGfTc6vUr77CQEd8tfq7E3Il e2wCXFd7d0BQC0kQE8g4aW47RULf6H84mVYf7IDD+/Z8o2L998DFYhoeqsta/cJg8x+M amOxYYDq9ejE1Uxi3RChPjSmKuKf+kCNKovtt0yPRc+WcRXHYRVC9CAyv07LnobfyHYL 6JA9h0Wt0vgno5wM+Mg9zpZ2n6B1BP/Fm3Nuo1/GbY/SkVf47Cvmyr/aHR04KUUP0VyD v45w== X-Received: by 10.25.15.213 with SMTP id 82mr5050246lfp.98.1447267816786; Wed, 11 Nov 2015 10:50:16 -0800 (PST) Received: from ?IPv6:2a02:6b8:0:408:91ae:525f:706e:eb65? ([2a02:6b8:0:408:91ae:525f:706e:eb65]) by smtp.googlemail.com with ESMTPSA id ds2sm1656724lbc.33.2015.11.11.10.50.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Nov 2015 10:50:15 -0800 (PST) To: bug-coreutils@gnu.org From: Alexander Kindyakov Subject: Possible bug in sort --check --key Message-ID: <56438DE6.1050007@gmail.com> Date: Wed, 11 Nov 2015 21:50:14 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 11 Nov 2015 13:51:46 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Hello! In sort man page nothing told about working sort --check with '--key' option. IMHO this behaviour is strange: This case is succeeded: $ echo -e '1\t2\n1\t1' | LC_ALL=C sort --key=1b,1 --check --stable --field-separator=$'\t' But this (without option '--stable') is failed: $ echo -e '1\t2\n1\t1' | LC_ALL=C sort --key=1b,1 --check --field-separator=$'\t' sort: -:2: disorder: 1 1 It seems to me both of situation is equal with relation of line key, why does the output is different? Sincerely yours, Alexander K From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 11 15:01:36 2015 Received: (at control) by debbugs.gnu.org; 11 Nov 2015 20:01:36 +0000 Received: from localhost ([127.0.0.1]:33595 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZwbaJ-0007fD-RS for submit@debbugs.gnu.org; Wed, 11 Nov 2015 15:01:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50669) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZwbZy-0007eg-9z; Wed, 11 Nov 2015 15:01:33 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 0E0D280081; Wed, 11 Nov 2015 20:01:13 +0000 (UTC) Received: from [10.3.113.115] (ovpn-113-115.phx2.redhat.com [10.3.113.115]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tABK1C3P016746; Wed, 11 Nov 2015 15:01:12 -0500 Subject: Re: bug#21880: Possible bug in sort --check --key To: Alexander Kindyakov , 21880-done@debbugs.gnu.org References: <56438DE6.1050007@gmail.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <56439E83.6040906@redhat.com> Date: Wed, 11 Nov 2015 13:01:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <56438DE6.1050007@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="XNMr4eDt6TNSfHqmMQv7EBI97GragwBUu" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Spam-Score: -5.3 (-----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.3 (-----) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --XNMr4eDt6TNSfHqmMQv7EBI97GragwBUu Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable tag 21880 notabug thanks On 11/11/2015 11:50 AM, Alexander Kindyakov wrote: > Hello! >=20 > In sort man page nothing told about working sort --check with '--key' > option. IMHO this behaviour is strange: Thanks for the report. >=20 > This case is succeeded: >=20 > $ echo -e '1\t2\n1\t1' | LC_ALL=3DC sort --key=3D1b,1 --check --stable= > --field-separator=3D$'\t' 'echo -e' is not portable; better is using printf. Let's see what sort was looking at here (it's a shame that --check and --debug can't be used at the same time; but seeing _what_ gets sorted without --check explains whether --check will succeed): $ printf '1\t2\n1\t1\n' | LC_ALL=3DC sort --debug -k1b,1 -s -t$'\t' sort: using simple byte comparison 1>2 _ 1>1 _ $ So, in this version, you were checking JUST the first field, and nothing else; among the portion of the line checked, everything was identical, so --check has nothing to complain about. >=20 > But this (without option '--stable') is failed: >=20 > $ echo -e '1\t2\n1\t1' | LC_ALL=3DC sort --key=3D1b,1 --check > --field-separator=3D$'\t' > sort: -:2: disorder: 1 1 Again, look at the debug output: $ printf '1\t2\n1\t1\n' | LC_ALL=3DC sort --debug -k1b,1 -t$'\t' sort: using simple byte comparison 1>1 _ ___ 1>2 _ ___ $ Notice that the removal of --stable behaves as if you had added another --key=3D1 (that is, sort the ENTIRE line as a last-resort key); and now that you have the entire line involved, --check can indeed see an out-of-order difference in the input. >=20 > It seems to me both of situation is equal with relation of line key, wh= y > does the output is different? The output differs because of your use of --stable. Therefore, this is not a bug in sort, and I'm closing this bug. However, do feel free to add further comments to this thread. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --XNMr4eDt6TNSfHqmMQv7EBI97GragwBUu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWQ56DAAoJEKeha0olJ0NqNXsIAKjcnWGaz/e2SLQIm6v3R+oH rpom7SsaM1RN3bXS5H4xiu6TcHlmvEkhigRnAl/b/pFd2b74cDOkBotfNmnL3c8b zinm2ewgC/U10yFv7DxiKTWU1VKdUbr779mY7Jd/JWj522mlhM6CqxqDbmxwHAOJ aZ2dPj4J6xG9ugU6X8wIcA8cI06JVOOQO4I6ajDDEelgiVDtsSi8rrWQpAvXy2g2 5hpN2DnozK8CbJdTLwdPxx71TYMLTTd3A8+hL/3qvcapL8KSxADJ29G95OmD3WaS //hkprSTjocT7cjbC48TNsFQGs3Arzxkxtv44f3LE/6nvltfcH9gF9i9oKmEVAI= =NCHW -----END PGP SIGNATURE----- --XNMr4eDt6TNSfHqmMQv7EBI97GragwBUu-- From unknown Fri Sep 05 15:37:08 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 10 Dec 2015 12: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