Red Hat Bugzilla – Bug 43880
ls does not use punctuation when sorting
Last modified: 2007-04-18 12:33:36 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.75 [en] (X11; U; Linux 2.2.16-3.msu i686)
Description of problem:
When I use ls, it does not include the punctuation in its sort. Ls will
show the following three files as:
file.c filemake.c file.o
Previous versions of ls give
file.c file.o filemake.c
Steps to Reproduce:
1. touch file.c file.o filemake.c
Actual Results: file.c filemake.c file.o
Expected Results: file.c file.o filemake.c
could not find an option to change the sort
This is even more obvious with "ls -a" in a directory with both hidden and non-
hidden files. The hidden (or dot) files should all precede the non-hidden
files, but, in fact, they are sorted as if the leading dot were not present.
You can fix this by replacing all the references to 'strcoll' with strcmp.
This returns 'ls' to the default behaviour. It seems that the locale
configuration is broken but I don't know how to fix this myself so this is
a viable workaround.
Created attachment 21485 [details]
RPM with fixed 'ls' command
locale-awareness can hardly be considered a bug.
If you don't like it,
LC_COLLATE=C DOES NOT FIX THIS PROBLEM!
OOPS! Sorry about that. LC_COLLATE=C does fix the problem.
Locale awareness IS a bug if it doesn't order things correctly. File names are
not required to be words in any language. The sorting order of filenames is
not neccessarily the same as words for the English (or other) language. This
is an inappropriate place to use locale sorting.
I have no objection to using locale based sorts for the appropriate items or,
to stretch a point, even with 'ls': PROVIDED IT MAINTAINS THE STANDARD SORTING
ORDER. This does not and therefore this is a bug, we should not have to set
environment variables to make 'ls' behave correctly. Not only that but I
presume this fix stops locale sorts working where you actually want it to work?
This should be fixed: it is a bug!
It is not locale awareness that is the problem. The problem is that the 'ls'
command, one of the most basic commands in unix and linux no longer functions as
it always has in the past.
I don't mind if a new flag is added to 'ls' to enable locale awareness sorting,
but to remove it, one should not have to include a flag or set an environmental
When I place punctuation in the middle of my file names, it should be assumed
that I wanted to put it there, so this punctuation should not be arbitrarily
removed from the sort.
Then export LC_COLLATE=C
The current behavior is the way the fileutils maintainers and POSIX want it.
Yes, this is not the way traditional ls worked, and I don't really like it
either (my initial fix was to make locale sorting optional, introducing a new
flag needed to activate it, but I got overruled).