coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: question about behavior of sort -n -t,


From: Gabriel Gaster
Subject: Re: question about behavior of sort -n -t,
Date: Wed, 9 Oct 2013 12:22:03 -0500


On Tuesday, October 8, 2013 at 8:48 PM, Eric Blake wrote:

> > the question in my mind remains: if a user specifies a field-separator 
> > shouldn't that override the locale?
> 
> 
> No, because POSIX requires that -n parse as many characters as possible
> regardless of locale, unless you explicitly ask to limit the sort to a
> specific key.
> 
> Perhaps less likely to be used in real life, but still apropos to the
> example:
> 
> $ printf '1202\n2011\n' | LC_ALL=C sort --debug -t0 -s -n -k1,1
> sort: using simple byte comparison
> 2011
> _
> 1202
> __
> 
> $ printf '1202\n2011\n' | LC_ALL=C sort --debug -t0 -s -n
> sort: using simple byte comparison
> 1202
> ____
> 2011
> ____
> 
> And you'll get the same behavior on Solaris or BSD sort (at least,
> assuming they don't have blatant POSIX compliance bugs). Once you
> understand WHY the above example has two different sorts, based on
> whether -k is used, you'll understand why we can't stop parsing -n at a
> comma even for -t, in a non-C locale.
> 
> > It seems that the locale overrides specific arguments to sort (in this 
> > case, field-separator=, ).
> 
> Rather, the lack of -k determines how far -n will parse, regardless of
> locale; it's just that some locales let -n parse farther than others.
> 
> -- 
> Eric Blake eblake redhat com +1-919-301-3266
> Libvirt virtualization library http://libvirt.org






reply via email to

[Prev in Thread] Current Thread [Next in Thread]