Sorting a simple textfile containing month names with sort and option -M doesn't sort as expected. It seems like it simply sorts it alphabetically instead unless the -s option is also specifien in which case it doesn't do any sorting at all. I have tested this with sort 5.2.0 and sort 5.0.91 and is doesn't work in either of them. However with an old version 2.1 of sort from the textutils package it works perfectly. I have tested this on an older gentoo installation from that time where textutils was installed by default instead of coreutils. Reproducible: Always Steps to Reproduce: 1. Create a textfile containing monthnames. Example: May JAN Apr Foobar March Jun FEB 2. sort it by executing: sort -M -s testfil 3. Examine the result. Actual Results: May JAN Apr Foobar March Jun FEB Expected Results: Foobar JAN FEB March Apr May Jun Copying the older version of sort from my old gentoo installation to a new machine works. I think that indicates that it isn't a problem in some libraries (glibc) but in the sort program itself. The manpage mentions something about environment variables LC_ALL, LC_TIME and others. I have tried setting these to different values like C and en_US in different combinations but it doesn't do anything.
one of the patches is causing this disturbing behaviour -- investigating.
Also confirmed not working in 5.2.1.
Hm...seems to me it's a small typo in the `i18n' patch. `Sort' keeps a table of month names in the current locale, converted to upper case (initialized in `inittables()'). However... with `i18n' applied, this initialization is done in `inittables_mb()'... the month names chars are converted to uppercase (pwc), but the unconverted characters (wc) are stored in `monthtab'. Line 2573 in `coreutils-5.2.1-i18n-0.1.patch', mblength = wcrtomb (mbc, wc, &state_wc); should be mblength = wcrtomb (mbc, pwc, &state_wc); Line numbers in older versions, coreutils-5.0.91-i18n-0.2.patch, 2671 coreutils-5.2.0-i18n-0.1.patch, 2573
200
I'll get a new revision out shortly with a fixed patchset + a new selinux patchset ETA: 1 day
coreutils-5.2.1-r1 fixes this.
coreutils-5.2.1 is still the latest version marked stable on x86 so most gentoo systems still contain this bug.