GNU bug report logs - #69901
(echo a; echo b) | sort -nu looses some data

Previous Next

Package: coreutils;

Reported by: Rafal Maszkowski <rzm <at> icm.edu.pl>

Date: Tue, 19 Mar 2024 18:26:04 UTC

Severity: normal

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

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 69901 in the body.
You can then email your comments to 69901 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#69901; Package coreutils. (Tue, 19 Mar 2024 18:26:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Rafal Maszkowski <rzm <at> icm.edu.pl>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Tue, 19 Mar 2024 18:26:05 GMT) Full text and rfc822 format available.

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

From: Rafal Maszkowski <rzm <at> icm.edu.pl>
To: bug-coreutils <at> gnu.org
Subject: (echo a; echo b) | sort -nu  looses some data
Date: Tue, 19 Mar 2024 16:33:09 +0100
Sort with -n and -u options works correctly for numbers:

(echo 10; echo 11) | sort -nu
10
11

but looses data when used with non-numbers:

(echo a; echo b) | sort -nu
a

(echo 1.0; echo 1.1) | sort -nu
1.0

I have tested this on versions 8.32 and 9.2 default for Debian 11 and
12, and additionally compiled version 9.4. The --debug option advised in
README does not say anything helpful:

(echo a; echo b) | sort --debug -nu
sort: text ordering performed using simple byte comparison
a
^ no match for key

R.
-- 
„Walczy on z całym zapamiętaniem przeciwko intelektowi” - z akt personalnych prof. A. Baeumlera




Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Tue, 19 Mar 2024 22:08:01 GMT) Full text and rfc822 format available.

Notification sent to Rafal Maszkowski <rzm <at> icm.edu.pl>:
bug acknowledged by developer. (Tue, 19 Mar 2024 22:08:02 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Rafal Maszkowski <rzm <at> icm.edu.pl>
Cc: 69901-done <at> debbugs.gnu.org
Subject: Re: bug#69901: (echo a; echo b) | sort -nu looses some data
Date: Tue, 19 Mar 2024 15:07:01 -0700
On 3/19/24 08:33, Rafal Maszkowski wrote:
> he --debug option advised in
> README does not say anything helpful:
> 
> (echo a; echo b) | sort --debug -nu
> sort: text ordering performed using simple byte comparison
> a
> ^ no match for key

That diagnostic message is helpful. It's telling you that there's no 
number, so everything sorts as being the same, which means 'sort -nu' 
(correctly) outputs just one line.

'sort' has behaved this way for quite some time, and POSIX requires this 
behavior.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 17 Apr 2024 11:24:11 GMT) Full text and rfc822 format available.

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

Previous Next


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