[Fedora-livecd-list] LANGUAGE trumps LC_ALL

Jim Meyering jim at meyering.net
Wed Mar 3 20:04:10 UTC 2010


Mads Kiilerich wrote:
> Regarding
>> user:        Jim Meyering <meyering at redhat.com>
>> date:        Wed Dec 16 13:46:07 2009 -0500
>> files:       tools/livecd-iso-to-disk.sh
>> description:
>> livecd-iso-to-disk.sh: use LC_ALL=C, not LANG=C, since LC_ALL trumps
>> all other envvars, including LANG.  For example,
>>   $ LC_ALL=fr_FR.UTF-8 LANG=C /bin/cat no-such
>>   /bin/cat: no-such: Aucun fichier ou dossier de ce type
>
> be aware that LANGUAGE trumps:
>
> $ LC_ALL=fr_FR.UTF-8 LANGUAGE=da_DK /bin/cat no-such
> /bin/cat: no-such: Ingen sådan fil eller filkatalog
>
> $ LANGUAGE=da_DK.UTF-8 LC_ALL=fr_FR.UTF-8 LANG=C /sbin/parted
> WARNING: You are not superuser.  Watch out for permissions.
> /dev/mapper/control: open failed: Adgang nægtet
> Failure to communicate with kernel device-mapper driver.
> Fejl: Ingen enhed fundet
> Forsøg igen/Retry/Annullér/Cancel?

Thanks for the info.
Beware that using the LANGUAGE envvar like that takes advantage
of a glibc extension, and hence is not portable.
Knowing this, I've added "LANGUAGE" to the list of envvars
that coreutils unsets when running its test suite.
(for many Perl scripts it was already handled in individual scripts, but
this change also protects shell scripts, none of which guarded against this)

>From 837924c5a3554f0f875625ec08c50de3708d8ae9 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Wed, 3 Mar 2010 20:55:27 +0100
Subject: [PATCH] tests: don't let the LANGUAGE envvar perturb tests

* tests/envvar-check (vars): Add LANGUAGE to the list of envvars
to unset, if possible.  At least in glibc (as an extension to POSIX),
its value actually trumps LC_ALL when the default locale is not C:
  $ LC_ALL=C LANGUAGE=fr_FR.UTF-8 /bin/cat no-such
  /bin/cat: no-such: No such file or directory
  $ LC_ALL=es_ES LANGUAGE=fr_FR.UTF-8 /bin/cat no-such
  /bin/cat: no-such: Aucun fichier ou dossier de ce type
Prompted by a report from Mads Kiilerich.
---
 tests/envvar-check |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tests/envvar-check b/tests/envvar-check
index 65fda9b..e31b941 100644
--- a/tests/envvar-check
+++ b/tests/envvar-check
@@ -31,6 +31,7 @@ vars='
   COLUMNS
   DF_BLOCK_SIZE
   DU_BLOCK_SIZE
+  LANGUAGE
   LS_BLOCK_SIZE
   LS_COLORS
   POSIXLY_CORRECT
--
1.7.0.1.464.g0adc7


More information about the livecd mailing list