From unknown Mon Aug 18 09:09:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41920: sort: bug report/feature request: warn is -t is effectively a no-op? Resent-From: Jacek Wielemborek Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 17 Jun 2020 12:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 41920 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 41920@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.159239779410691 (code B ref -1); Wed, 17 Jun 2020 12:44:02 +0000 Received: (at submit) by debbugs.gnu.org; 17 Jun 2020 12:43:14 +0000 Received: from localhost ([127.0.0.1]:50706 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlXPN-0002mH-LN for submit@debbugs.gnu.org; Wed, 17 Jun 2020 08:43:14 -0400 Received: from lists.gnu.org ([209.51.188.17]:34424) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlX5v-0002EV-Ni for submit@debbugs.gnu.org; Wed, 17 Jun 2020 08:23:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlX5v-0007dG-Dr for bug-coreutils@gnu.org; Wed, 17 Jun 2020 08:23:07 -0400 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]:40522) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlX5p-0001Qf-7m for bug-coreutils@gnu.org; Wed, 17 Jun 2020 08:23:06 -0400 Received: by mail-ej1-x631.google.com with SMTP id q19so2086727eja.7 for ; Wed, 17 Jun 2020 05:22:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=d33-pl.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=Q5jNBriqekeOm8K6RGtdSv/+E+wJ6HfOLWXBobsJBe4=; b=jM4/Ld19GSU2udcGVMpHipsnCCaGK2yFHpNcR3srX/0qk/GV+9iNH/zsz39ZDRVr8f lHvI652vj5Fiar/Q64tPqUa2Acft4y+pkGgw2HR2SWlvapfLmHbuFbINB48IQywuDNun si9z9DN/2+PWJ093WWGIOlm//joMIKXrJtpYhQg0dMeCuHrgSsuyGv+gs6/U/fG4eTTb yiAhUU2DQ9IwGnFJxwqXM0FqlMH6/zCIEFla2msxlwLyR2qmx+uX7iiKdXDzJqTcMD/J ji8XTUGKC6VHSAez/hWm2HaDM2UyMRx0hlLQwIXmNqq3HL/0JTkQrUvUrr4z4i2NxIwx ygeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Q5jNBriqekeOm8K6RGtdSv/+E+wJ6HfOLWXBobsJBe4=; b=WnxPWDI/Tg4uLjPpGb1NOzlbOmq14FvJsYUie6mPMSyeEBbie8fegU7S8SjzoVjnVS EjNfP40k8jr8nVEbGzOqMmw26x5d5XpAF5S7u8y0odlXClJtqD83v26KPXT4IWbGfPlH cZ5YTFjS8El9pWOE2Z19PrZN9z2ZWkFRkMH1sKZEef8aZ+vZ2Uehw1pgdAYJ/dGYqDsZ NhPgoCw3i8vcn14Y7nHC5s2wUe87wGrbOu0ktav//JK7mhpYd0IGOGQeRZ1R/EoGfTmv nGjeXsuxSkwk2E7t0mXAm7IdH5rGLnoW1qwwpTdLFgMjBrOyu8g6+6EBjoADVNE2ZlsE gcQA== X-Gm-Message-State: AOAM5301s31DdmwBOZeoSst9JIt+WZ5JiY6iYMbQk4HGX9FDYvs89wKg V48tw/FkpPoZ/DMsfpTJhLQbaET4ZxYwDxySePA3p14qbZM= X-Google-Smtp-Source: ABdhPJxruk+p/a34km2cRPamqW9yi7G+BnwmnfUtfJMk6bIjlzFDUwUgRYjOd2+uU7axsn68qric2kb/uKbjctt9SrU= X-Received: by 2002:a17:906:c102:: with SMTP id do2mr7126147ejc.126.1592396578355; Wed, 17 Jun 2020 05:22:58 -0700 (PDT) MIME-Version: 1.0 From: Jacek Wielemborek Date: Wed, 17 Jun 2020 14:22:47 +0200 Message-ID: Content-Type: multipart/alternative; boundary="000000000000652cd205a846b800" Received-SPF: none client-ip=2a00:1450:4864:20::631; envelope-from=mail@d33.pl; helo=mail-ej1-x631.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Mailman-Approved-At: Wed, 17 Jun 2020 08:43:10 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 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: -3.3 (---) --000000000000652cd205a846b800 Content-Type: text/plain; charset="UTF-8" Hi! First of all, thanks for maintaining GNU sort! I use it very often and love its performance. Today I spent some time debugging and realized that my bug was caused by a wrong GNU invocation ("sort -k1,1 -t," instead of "sort -t, -k1,1"). Could sort warn when -t is effectively a no-op because it was specified after last -k? I know that `find` warns the user if arguments are in a wrong order, perhaps it would make sense to add it here as well? (I read FAQ/list of gotchas, but believe that my case is a bit different compared to the ones listed there) Cheers, d33tah --000000000000652cd205a846b800 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi!

First of all, thanks for= maintaining GNU sort! I use it very often and love its performance.
<= div>
Today I spent some time debugging and realized that my b= ug was caused by a wrong GNU invocation ("sort -k1,1 -t," instead= of "sort -t, -k1,1"). Could sort warn when -t is effectively a n= o-op because it was specified after last -k? I know that `find` warns the u= ser if arguments are in a wrong order, perhaps it would make sense to add i= t here as well?

(I read FAQ/list of gotchas, but b= elieve that my case is a bit different compared to the ones listed there)

Cheers,
d33tah
--000000000000652cd205a846b800-- From unknown Mon Aug 18 09:09:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41920: sort: bug report/feature request: warn is -t is effectively a no-op? Resent-From: Eric Blake Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 17 Jun 2020 13:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41920 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Jacek Wielemborek , 41920@debbugs.gnu.org Received: via spool by 41920-submit@debbugs.gnu.org id=B41920.159240045614728 (code B ref 41920); Wed, 17 Jun 2020 13:28:02 +0000 Received: (at 41920) by debbugs.gnu.org; 17 Jun 2020 13:27:36 +0000 Received: from localhost ([127.0.0.1]:50757 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlY6J-0003pS-SR for submit@debbugs.gnu.org; Wed, 17 Jun 2020 09:27:36 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:20446 helo=us-smtp-1.mimecast.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlY6H-0003pF-Ft for 41920@debbugs.gnu.org; Wed, 17 Jun 2020 09:27:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592400453; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SaA6wS4F5eFtbOb1reB7DB4u+Q9o7D9lCMhI43FqTBw=; b=Nxs8yG22EGKHICmtNsdDXRJ9rkSg5+m50n6+9RpVnyPNE3FVu1961UCa4wVBeRlqDJ9XsF yv1SF7XXQ/MEHCkKlA33COjhnDgF0CpX6LILKrrp6hbESODj9FaNbmZWtAOKE7nUKL0UW9 AJ0c6b3OASr1Y/LnnDDvp29Esh7kbPM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-247-lmUDO5efOnqcuazfTm1mHw-1; Wed, 17 Jun 2020 09:27:30 -0400 X-MC-Unique: lmUDO5efOnqcuazfTm1mHw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B811E873430; Wed, 17 Jun 2020 13:27:28 +0000 (UTC) Received: from [10.3.112.27] (ovpn-112-27.phx2.redhat.com [10.3.112.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5EF5179311; Wed, 17 Jun 2020 13:27:28 +0000 (UTC) References: From: Eric Blake Organization: Red Hat, Inc. Message-ID: Date: Wed, 17 Jun 2020 08:27:27 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 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: -1.0 (-) On 6/17/20 7:22 AM, Jacek Wielemborek wrote: > Hi! > > First of all, thanks for maintaining GNU sort! I use it very often and love > its performance. > > Today I spent some time debugging and realized that my bug was caused by a > wrong GNU invocation ("sort -k1,1 -t," instead of "sort -t, -k1,1"). Could > sort warn when -t is effectively a no-op because it was specified after > last -k? Except that statement does not appear to be true. sort does not care whether -t comes before or after -k; there is no interlocking between the two options (looking at the source code, nothing under case 't' [1] depends on the current set of keys, and nothing under case 'k' [2] depends on the current 'tab'). [1] https://git.sv.gnu.org/cgit/coreutils.git/tree/src/sort.c#n4520 [2] https://git.sv.gnu.org/cgit/coreutils.git/tree/src/sort.c#n4441 To convince me otherwise, could you include actual input where the relative ordering of the two options produces different output? > I know that `find` warns the user if arguments are in a wrong > order, perhaps it would make sense to add it here as well? We have 'sort --debug' for this sort of things. If the ordering truly mattered, then yes, --debug should warn about that. But I can't see the ordering matter. Here's what I tried, where the first two tries show that the position of -t, doesn't affect the output, and the third shows that omitting -t, does matter: $ printf '1,2 3\n2,1 4\n' | LC_ALL=C sort -k2,2 -t, --debug sort: text ordering performed using simple byte comparison 2,1 4 ___ _____ 1,2 3 ___ _____ $ printf '1,2 3\n2,1 4\n' | LC_ALL=C sort -t, -k2,2 --debug sort: text ordering performed using simple byte comparison 2,1 4 ___ _____ 1,2 3 ___ _____ $ printf '1,2 3\n2,1 4\n' | LC_ALL=C sort -k2,2 --debug sort: text ordering performed using simple byte comparison sort: leading blanks are significant in key 1; consider also specifying 'b' 1,2 3 __ _____ 2,1 4 __ _____ I'll leave this bug open a bit longer to allow you to reply with the counterexample that behaved differently based solely on ordering, but I'm inclined to close it if we can't come up with such a case. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org