GNU bug report logs - #76290
"sort -u" vs "sort -h -u": possible bug

Previous Next

Package: coreutils;

Reported by: Rupert Gallagher <ruga <at> protonmail.com>

Date: Fri, 14 Feb 2025 17:01:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Rupert Gallagher <ruga <at> protonmail.com>
Subject: bug#76290: closed (Re: bug#76290: "sort -u" vs "sort -h -u":
 possible bug)
Date: Tue, 18 Feb 2025 06:26:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#76290: "sort -u" vs "sort -h -u": possible bug

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 76290 <at> debbugs.gnu.org.

-- 
76290: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=76290
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Rupert Gallagher <ruga <at> protonmail.com>
Cc: 76290-done <at> debbugs.gnu.org
Subject: Re: bug#76290: "sort -u" vs "sort -h -u": possible bug
Date: Mon, 17 Feb 2025 22:25:12 -0800
On 2025-02-17 15:13, Rupert Gallagher via GNU coreutils Bug Reports wrote:
> I expect the program to do exactly what the manual says.

Here's what the manual says about -u in 
<https://www.gnu.org/software/coreutils/manual/html_node/sort-invocation.html#index-uniquifying-output>:

>     Normally, output only the first of a sequence of lines that compare equal....
> 
>     This option also disables the default last-resort comparison.
> 
>     The commands sort -u and sort | uniq are equivalent, but this equivalence does not extend to arbitrary sort options. For example, sort -n -u inspects only the value of the initial numeric string when checking for uniqueness, whereas sort -n | uniq inspects the entire line.

This is the part of the manual that you're disagreeing with. The example 
in my previous email (an example that you did not reply to) is a 
demonstration of this part of the manual.

I am taking the liberty of closing this bug report, as "sort" is 
behaving as documented here.


[Message part 3 (message/rfc822, inline)]
From: Rupert Gallagher <ruga <at> protonmail.com>
To: "bug-coreutils <at> gnu.org" <bug-coreutils <at> gnu.org>
Subject: "sort -u" vs "sort -h -u": possible bug
Date: Fri, 14 Feb 2025 15:44:34 +0000
[Message part 4 (text/plain, inline)]
>echo -e "CVE-2018-13787\nCVE-2019-16649\nCVE-2019-16650\nCVE-2020-15046\nCVE-2018-13787"
CVE-2018-13787 <---
CVE-2019-16649
CVE-2019-16650
CVE-2020-15046CVE-2018-13787 <---

>echo -e "CVE-2018-13787\nCVE-2019-16649\nCVE-2019-16650\nCVE-2020-15046\nCVE-2018-13787" | sort
CVE-2018-13787 <---
CVE-2018-13787 <---
CVE-2019-16649
CVE-2019-16650
CVE-2020-15046

>echo -e "CVE-2018-13787\nCVE-2019-16649\nCVE-2019-16650\nCVE-2020-15046\nCVE-2018-13787" | sort -u
CVE-2018-13787 <---
CVE-2019-16649
CVE-2019-16650
CVE-2020-15046

Problem:

>echo -e "CVE-2018-13787\nCVE-2019-16649\nCVE-2019-16650\nCVE-2020-15046\nCVE-2018-13787" | sort -h -uCVE-2018-13787
[Message part 5 (text/html, inline)]

This bug report was last modified 92 days ago.

Previous Next


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