Hi David,
I think the only true solution here is to create a test program.
I noticed that the return value of setlocale() isn't checked by nmh
programs. Should it be? I think so.
Me too.
I got there by wondering if we could use mhparam as the test program.
I was also digging for a portable test and found much code ignores
setlocale()'s value, e.g.
http://codesearch.debian.net/search?q=\bsetlocale\b+package%3Acoreutils
I guess it's because POSIX states an invalid locale changes nothing, the
locale "C" exists everywhere, and it is the default.
$ seq 3 | ltrace -e setlocale sort | fmt
setlocale(6, "") = "en_GB.utf8"
setlocale(3, NULL) = "en_GB.utf8"
setlocale(2, NULL) = "en_GB.utf8"
1 2 3
+++ exited (status 0) +++
$
$ seq 3 | LC_ALL=foobar ltrace -e setlocale sort | fmt
setlocale(6, "") = NULL
setlocale(3, NULL) = "C"
setlocale(2, NULL) = "C"
1 2 3
+++ exited (status 0) +++
$
I turned up
One possible fix would be for "sort" to report an error message if
setlocale fails. However, this would have negative consequences.
I've been on systems that behave that way, and whenever you set the
locale to something "wrong", you start getting diagnostics from
nearly every program that you run. The normal Unix utility
tradition is therefore to ignore setlocale failures, and silently
fall back on the POSIX locale.
-- https://savannah.gnu.org/bugs/?11004#comment6
So that might explain coreutils' behaviour. I can see that if every
command exit(1)s soon into main() that it would be a bit bewildering for
the novice. Perhaps nmh should just issue a stderr warning and then
continue, à la perl, but a bit more quietly?
$ LC_ALL=foo perl -e 42
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "foo",
LANG = "en_GB.utf8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
$ echo $?
0
$
Cheers, Ralph.
_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers