bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: Iconsistent ls sorting with and without `v'


From: Jim Meyering
Subject: Re: Iconsistent ls sorting with and without `v'
Date: Sat, 10 May 2003 11:39:14 +0200

Andrey Borzenkov <address@hidden> wrote:
> info ls
>
> `-v'
> `--sort=version'
>      Sort by version name and number, lowest first.  It behaves like a
>      default sort, except that each sequence of decimal digits is
>      treated numerically as an index/version number.  (*Note More
>      details about version sort::.)
>
> where default sort is defined as ...
>
>    By default, the output is sorted alphabetically, according to the
> locale settings in effect.
>
> {pts/2}% ls
> a  A  b  B  c  C
> {pts/2}% ls -v
> A  B  C  a  b  c
> {pts/2}% echo $LANG
> ru_RU.KOI8-R
>
> The first output (without -v) is correct according to locale setings
> (I do not like this order but it is not related to the problem :)

Thank you for the complete problem report!

ls -v uses the strverscmp function.
The inconsistency you noticed is due to the fact that the strverscmp
function (as documented):

  ... does not use the locale category  LC_COLLATE,  so  is  meant
  mostly for situations where the strings are expected to be in ASCII.

As you've probably guessed, this is not a bug in ls,
but rather a case of insufficient documentation.

I've just added the following to the coreutils texinfo documentation:

Index: doc/coreutils.texi
===================================================================
RCS file: /fetish/cu/doc/coreutils.texi,v
retrieving revision 1.108
diff -u -p -u -p -r1.108 coreutils.texi
--- doc/coreutils.texi  10 May 2003 06:27:04 -0000      1.108
+++ doc/coreutils.texi  10 May 2003 09:35:00 -0000
@@ -5388,6 +5388,12 @@ fractional one:
       abc-1.01a.tgz      abc-1.012b.tgz
 @end example
 
+This functionality is implemented using the @code{strverscmp} function.
address@hidden/Array Comparison, , , libc, The GNU C Library Reference Manual}.
+One result of that implementation decision is that @code{ls -v} does not
+use the locale category, @env{LC_COLLATE}.  As a result, non-numeric prefixes
+are sorted as if @env{LC_COLLATE} were set to @code{C}.
+
 @node General output formatting
 @subsection General output formatting
 




reply via email to

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