GNU bug report logs - #55622
Bug in sort with keys and reverse, and version-sort and reverse

Previous Next

Package: coreutils;

Reported by: Larry Ploetz <lploetz <at> gmail.com>

Date: Wed, 25 May 2022 04:02:02 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 55622 in the body.
You can then email your comments to 55622 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#55622; Package coreutils. (Wed, 25 May 2022 04:02:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Larry Ploetz <lploetz <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Wed, 25 May 2022 04:02:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Larry Ploetz <lploetz <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: Bug in sort with keys and reverse, and version-sort and reverse
Date: Tue, 24 May 2022 19:00:04 -0700
[Message part 1 (text/plain, inline)]
I think I've found a bug in sort (git branch master). The --reverse flag 
seems to be ignored when --keys are supplied.

   larryp-MBP:bin larry$ ./sort --version
   sort (GNU coreutils) 9.1.17-a351f
   Copyright (C) 2022 Free Software Foundation, Inc.
   License GPLv3+: GNU GPL version 3 or later<https://gnu.org/licenses/gpl.html>.
   This is free software: you are free to change and redistribute it.
   There is NO WARRANTY, to the extent permitted by law.

   Written by Mike Haertel and Paul Eggert.
   larryp-MBP:bin larry$ ./sort -r <<< $'a\nb'
   b
   a
   larryp-MBP:bin larry$ ./sort -rk1,1 <<< $'a\nb'
   a
   b

This may be related to a bug reported in February where --version-sort 
sorted incorrectly.

   larryp-MBP:bin larry$ ./sort -Vr <<< $'1\n2'
   1
   2
   larryp-MBP:bin larry$ ./sort -V <<< $'1\n2'
   1
   2

Current version:

   larryp-MBP:bin larry$ sort --version
   sort (GNU coreutils) 9.1
   Copyright (C) 2022 Free Software Foundation, Inc.
   License GPLv3+: GNU GPL version 3 or later<https://gnu.org/licenses/gpl.html>.
   This is free software: you are free to change and redistribute it.
   There is NO WARRANTY, to the extent permitted by law.

   Written by Mike Haertel and Paul Eggert.
   larryp-MBP:bin larry$ sort -rk1,1 <<< $'a\nb'
   b
   a

Thanks,
· Larry

[Message part 2 (text/html, inline)]

Reply sent to Pádraig Brady <P <at> draigBrady.com>:
You have taken responsibility. (Wed, 25 May 2022 08:54:02 GMT) Full text and rfc822 format available.

Notification sent to Larry Ploetz <lploetz <at> gmail.com>:
bug acknowledged by developer. (Wed, 25 May 2022 08:54:02 GMT) Full text and rfc822 format available.

Message #10 received at 55622-done <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Larry Ploetz <lploetz <at> gmail.com>, 55622-done <at> debbugs.gnu.org
Subject: Re: bug#55622: Bug in sort with keys and reverse, and version-sort
 and reverse
Date: Wed, 25 May 2022 09:53:08 +0100
On 25/05/2022 03:00, Larry Ploetz wrote:
> I think I've found a bug in sort (git branch master). The --reverse flag
> seems to be ignored when --keys are supplied.
> 
>      larryp-MBP:bin larry$ ./sort --version
>      sort (GNU coreutils) 9.1.17-a351f
>      Copyright (C) 2022 Free Software Foundation, Inc.
>      License GPLv3+: GNU GPL version 3 or later<https://gnu.org/licenses/gpl.html>.
>      This is free software: you are free to change and redistribute it.
>      There is NO WARRANTY, to the extent permitted by law.
> 
>      Written by Mike Haertel and Paul Eggert.
>      larryp-MBP:bin larry$ ./sort -r <<< $'a\nb'
>      b
>      a
>      larryp-MBP:bin larry$ ./sort -rk1,1 <<< $'a\nb'
>      a
>      b

Thanks for the report.
I pushed the following to address this
https://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=4e0167ea1

The existing tests are sufficient to catch this.

thanks!
Pádraig





Information forwarded to bug-coreutils <at> gnu.org:
bug#55622; Package coreutils. (Wed, 25 May 2022 18:29:01 GMT) Full text and rfc822 format available.

Message #13 received at 55622 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: 55622 <at> debbugs.gnu.org, P <at> draigBrady.com, lploetz <at> gmail.com
Subject: Re: bug#55622: Bug in sort with keys and reverse, and version-sort
 and reverse
Date: Wed, 25 May 2022 11:28:21 -0700
[Message part 1 (text/plain, inline)]
Thanks, Pádraig, for fixing that. And thanks, Larry, for reporting that.

> The existing tests are sufficient to catch this.

Yes, evidently I forgot to run 'make check', which I usually do. I'll 
try to not forget next time....

I installed the attached further patches to (1) coalesce duplicate code 
and explain why it's needed and (2) tweak performance a tiny bit.
[0001-sort-refactor-tricky-diff-reversal.patch (text/x-patch, attachment)]
[0002-sort-tune-diff_reversed.patch (text/x-patch, attachment)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#55622; Package coreutils. (Wed, 25 May 2022 18:51:02 GMT) Full text and rfc822 format available.

Message #16 received at 55622 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: 55622 <at> debbugs.gnu.org, P <at> draigBrady.com, lploetz <at> gmail.com
Subject: Re: bug#55622: Bug in sort with keys and reverse, and version-sort
 and reverse
Date: Wed, 25 May 2022 11:50:37 -0700
[Message part 1 (text/plain, inline)]
I installed the attached spelling fix to a comment in my previous patch.
[0001-maint-spelling-fix.patch (text/x-patch, attachment)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 23 Jun 2022 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 280 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.