Bug 55251
Summary: | ls POSIX compliance disturbs normalcy | ||||||
---|---|---|---|---|---|---|---|
Product: | [Retired] Red Hat Linux | Reporter: | Neil McNeight <mcneight> | ||||
Component: | fileutils | Assignee: | Bernhard Rosenkraenzer <bero> | ||||
Status: | CLOSED NOTABUG | QA Contact: | Aaron Brown <abrown> | ||||
Severity: | medium | Docs Contact: | |||||
Priority: | medium | ||||||
Version: | 7.2 | CC: | teg | ||||
Target Milestone: | --- | ||||||
Target Release: | --- | ||||||
Hardware: | All | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2001-10-31 06:11:45 UTC | Type: | --- | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Attachments: |
|
Description
Neil McNeight
2001-10-28 09:55:08 UTC
Created attachment 35282 [details]
Restores normalcy to ls, and adds '-P, --posix' flags for occasional trips to Bizarro world (with mfn standing for mother-f**king normal)
The way it sorts "." is weird, but case insensitivity should be preserved. If you don't like the way POSIX systems should sort things, don't use a case insensitive, dot-ignoring locale. Add LC_COLLATE=C or LANG=C to /etc/sysconfig/i18n I repectfully disagree. While I don't have access to the POSIX standard, I would like to hope it was not the intention of its creators to break over 1 billion seconds of established behavior. I believe that changing locale, even temporarily, is a rather backwards way of looking at the problem. If this is official RedHat policy, then perhaps a warning should be placed when choosing a locale, to alert people that a locale other than C or POSIX may break the established usage of common utilities? If I use the sort command, then I might want it to skip over any non-alpha characters and sort alphabetically. But with ls, I expect .files to come before regular files. It's an established pattern, and breaks a lot of documentation as well as some code (bad code, but code nevertheless). To allow for any non-alpha files (including # and ~ files) to be placed at the top of a directory listing, and still allow the use of a normal locale, I suggest the following: static int compare_name (const struct fileinfo *file1, const struct fileinfo *file2) { register int temp = 0; if (!isalpha(file1->name[0]) && isalpha(file2->name[0])) { temp = -1; } else if (isalpha(file1->name[0]) && !isalpha(file2->name[0])) { temp = 1; } else { temp = strcoll (file1->name, file2->name); } return temp; } Since isalpha() is a locale aware function, under all circumstances non-alpha characters are placed in the directory listing first, followed by a case-insensitive listing of files after that. I'm not trying to be a stick in the mud, or I'd just stick with strcmp() and be done with it. But change just for the sake of change has never made me very happy. Just had a talk with the standards watchers; they say the current behavior is correct and must not be changed. Use LC_COLLATE=C. |