GNU bug report logs -
#21880
Possible bug in sort --check --key
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#21880: Possible bug in sort --check --key
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 21880 <at> debbugs.gnu.org.
--
21880: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21880
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
[Message part 3 (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)]
[Message part 5 (message/rfc822, inline)]
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
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.