Package: coreutils;
Reported by: Jorge Stolfi <stolfi <at> ic.unicamp.br>
Date: 2023年9月28日 10:17:03 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 66253 in the body.
You can then email your comments to 66253 AT debbugs.gnu.org in the normal way.
the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
bug-coreutils <at> gnu.org:bug#66253; Package coreutils.
(2023年9月28日 10:17:03 GMT) Full text and rfc822 format available.Jorge Stolfi <stolfi <at> ic.unicamp.br>:bug-coreutils <at> gnu.org.
(2023年9月28日 10:17:03 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Jorge Stolfi <stolfi <at> ic.unicamp.br> To: bug-coreutils <at> gnu.org Subject: sort manpage should be more explicit Date: 2023年9月28日 07:11:50 -0300
The full documentation of sort explains that numeric sorting (as in "sort -n") accepts a leading "-" sign, decimal points, thousands separators, etc, but does not accept an explicit "+" sign. Values with explicit "+" are treated as numeric 0 and ties are broken by alpha sort. However, the manpage only says that "-n" "compares according to string numerical value" -- and one would expect the numerical value of "+100" to be 100, not zero. It took me an hour to figure out that my "sort -n" was failing because of this "feature". Surely many users have wasted time too, or worse. So please either 1) explain precisely IN THE MANPAGE what is a valid number; 2) make numeric sort accept a leading "+", as users would expect; 3) make numeric sort abort with an error message if any field that is supposed to be sorted numerically is not a valid number. I think the best solution for users would be to implement all three of these... Thank you, and all the best --jorge -- Jorge Stolfi - Professor Titular/Full Professor Instituto de Computação/Computer Science Dept Universidade Estadual de Campinas/State University of Campinas Campinas, SP - Brazil
Pádraig Brady <P <at> draigBrady.com>:Jorge Stolfi <stolfi <at> ic.unicamp.br>:Message #10 received at 66253-done <at> debbugs.gnu.org (full text, mbox):
From: Pádraig Brady <P <at> draigBrady.com> To: Jorge Stolfi <stolfi <at> ic.unicamp.br>, 66253-done <at> debbugs.gnu.org Subject: Re: bug#66253: sort manpage should be more explicit Date: 2023年9月28日 12:22:35 +0100
On 28/09/2023 11:11, Jorge Stolfi wrote: > The full documentation of sort explains that numeric sorting (as in > "sort -n") accepts a leading "-" sign, decimal points, thousands > separators, etc, but does not accept an explicit "+" sign. Values with > explicit "+" are treated as numeric 0 and ties are broken by alpha sort. > > However, the manpage only says that "-n" "compares according to string > numerical value" -- and one would expect the numerical value of "+100" > to be 100, not zero. > > It took me an hour to figure out that my "sort -n" was failing because > of this "feature". Surely many users have wasted time too, or worse. > So please either > > 1) explain precisely IN THE MANPAGE what is a valid number; > > 2) make numeric sort accept a leading "+", as users would expect; > > 3) make numeric sort abort with an error message if any field that is > supposed to be sorted numerically is not a valid number. > > I think the best solution for users would be to implement all three of > these... > > Thank you, and all the best Note the --debug option really helps with all this: $ printf '%s\n' '+4' ' 5' '-1,2.3' | sort -s -n --debug sort: note numbers use ‘.’ as a decimal point in this locale -1,2.3 ______ +4 ^ no match for key 5 _ In saying that, sorting numbers is such a common use case, it's probably worth adding an extra couple of lines to the man page. I think I'll apply the following later: -n, --numeric-sort compare according to string numerical value. leading blanks, negative sign, decimal point, and thousands separators are supported. cheers, Pádraig
bug-coreutils <at> gnu.org:bug#66253; Package coreutils.
(2023年9月29日 01:12:01 GMT) Full text and rfc822 format available.Message #13 received at 66253 <at> debbugs.gnu.org (full text, mbox):
From: Paul Eggert <eggert <at> cs.ucla.edu> To: 66253 <at> debbugs.gnu.org, P <at> draigBrady.com, stolfi <at> ic.unicamp.br Subject: Re: bug#66253: sort manpage should be more explicit Date: 2023年9月28日 18:11:12 -0700
[Message part 1 (text/plain, inline)]
On 9/28/23 04:22, Pádraig Brady wrote: > > -n, --numeric-sort compare according to string numerical value. > leading blanks, negative sign, decimal > point, > and thousands separators are supported. Although a valiant effort this is likely to cause other trouble, as it uses multiple terms (blanks, decimal point, thousands separator) without explanation, and it omits the role of the locale. I suggest instead that we simply say "see the manual", and tighten up the manual to explain these and, while we're at it, other things (e.g., -0 vs 0). I gave that a shot by installing the attached. PS to Jorge: Changing behavior as you suggested would likely cause trouble, as many programs depend on the current behavior, which is standardized by POSIX here: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sort.html#tag_20_119_04
[0001-sort-improve-help.patch (text/x-patch, attachment)]
Debbugs Internal Request <help-debbugs <at> gnu.org>
to internal_control <at> debbugs.gnu.org.
(2023年10月27日 11:24:07 GMT) Full text and rfc822 format available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.