GNU bug report logs -
#21880
Possible bug in sort --check --key
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21880 in the body.
You can then email your comments to 21880 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#21880
; Package
coreutils
.
(Wed, 11 Nov 2015 18:52:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Alexander Kindyakov <akindyakov <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Wed, 11 Nov 2015 18:52:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hello!
In sort man page nothing told about working sort --check with '--key'
option. IMHO this behaviour is strange:
This case is succeeded:
$ echo -e '1\t2\n1\t1' | LC_ALL=C sort --key=1b,1 --check --stable
--field-separator=$'\t'
But this (without option '--stable') is failed:
$ echo -e '1\t2\n1\t1' | LC_ALL=C sort --key=1b,1 --check
--field-separator=$'\t'
sort: -:2: disorder: 1 1
It seems to me both of situation is equal with relation of line key, why
does the output is different?
Sincerely yours, Alexander K
Added tag(s) notabug.
Request was from
Eric Blake <eblake <at> redhat.com>
to
control <at> debbugs.gnu.org
.
(Wed, 11 Nov 2015 20:02:01 GMT)
Full text and
rfc822 format available.
Reply sent
to
Eric Blake <eblake <at> redhat.com>
:
You have taken responsibility.
(Wed, 11 Nov 2015 20:02:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Alexander Kindyakov <akindyakov <at> gmail.com>
:
bug acknowledged by developer.
(Wed, 11 Nov 2015 20:02:03 GMT)
Full text and
rfc822 format available.
Message #12 received at 21880-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tag 21880 notabug
thanks
On 11/11/2015 11:50 AM, Alexander Kindyakov wrote:
> Hello!
>
> In sort man page nothing told about working sort --check with '--key'
> option. IMHO this behaviour is strange:
Thanks for the report.
>
> This case is succeeded:
>
> $ echo -e '1\t2\n1\t1' | LC_ALL=C sort --key=1b,1 --check --stable
> --field-separator=$'\t'
'echo -e' is not portable; better is using printf.
Let's see what sort was looking at here (it's a shame that --check and
--debug can't be used at the same time; but seeing _what_ gets sorted
without --check explains whether --check will succeed):
$ printf '1\t2\n1\t1\n' | LC_ALL=C sort --debug -k1b,1 -s -t$'\t'
sort: using simple byte comparison
1>2
_
1>1
_
$
So, in this version, you were checking JUST the first field, and nothing
else; among the portion of the line checked, everything was identical,
so --check has nothing to complain about.
>
> But this (without option '--stable') is failed:
>
> $ echo -e '1\t2\n1\t1' | LC_ALL=C sort --key=1b,1 --check
> --field-separator=$'\t'
> sort: -:2: disorder: 1 1
Again, look at the debug output:
$ printf '1\t2\n1\t1\n' | LC_ALL=C sort --debug -k1b,1 -t$'\t'
sort: using simple byte comparison
1>1
_
___
1>2
_
___
$
Notice that the removal of --stable behaves as if you had added another
--key=1 (that is, sort the ENTIRE line as a last-resort key); and now
that you have the entire line involved, --check can indeed see an
out-of-order difference in the input.
>
> It seems to me both of situation is equal with relation of line key, why
> does the output is different?
The output differs because of your use of --stable. Therefore, this is
not a bug in sort, and I'm closing this bug. However, do feel free to
add further comments to this thread.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 10 Dec 2015 12:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 9 years and 272 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.