autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why if test "xSTRING1= "xSTRING2" (the 'x') ?


From: Eric Blake
Subject: Re: Why if test "xSTRING1= "xSTRING2" (the 'x') ?
Date: Mon, 26 Mar 2007 22:05:37 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.10) Gecko/20070221 Thunderbird/1.5.0.10 Mnenhy/0.7.4.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Bruce Korb on 3/26/2007 2:49 PM:
> The default locale is the C locale.  Nevertheless, one shell (not ksh
> or Solaris' sh)
> thinks it is okay for [a-z] to match 'B' even when all locale
> variables are undefined.
> In other words, this:
> 
>  unset LANG `env|sed -n 's/=.*//;/^LC_/p'`
>  ls [a-z]*
> 
> is insufficient.

According to POSIX, all programs start life in the C locale.  But bash,
and many other programs that use libintl, immediately invoke setlocale
(LC_ALL, ""), as recommended by the gettext documentation.  It is this
action which changes the current locale to the system default, if you do
not have any environment variables defined to tell the system which locale
YOU want.  If you don't like your system defaults, then blame the distros
that have chosen a non-C locale as the default when setlocale is invoked
with an empty string, rather than blaming bash.  If you are writing
portable shell scripts, get in the habit of setting LC_ALL=C near the
beginning.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGCJgR84KuGfSFAYARAlnqAKCNDnyNsoHxrINoTHdh6sy/mGku7QCfQgl0
ywXIOWQXl/jRZXFnrY3PhJw=
=rRQG
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]