I had a single line of only LANG="en_GB.UTF-8" in /etc/env.d/02locale; adding LC_TIME="POSIX" allows various scripts and stuff (I've written) to show the date properly, but I think I read somewhere that this is bad.
No idea about anything bad tho. Just for comparison.
Dale
:-) :-)
01-07-2011, 05:26 AM
Alan McKinnon
More locale oddness
Apparently, though unproven, at 03:49 on Friday 07 January 2011, Stroller did
opine thusly:
> Hi there,
>
> Can anyone else reproduce this, please, or tell me what behaviour is
> expected?
>
> $ locale
> LANG=en_GB.UTF-8
> LC_CTYPE="en_GB.UTF-8"
> LC_NUMERIC="en_GB.UTF-8"
> LC_TIME=en_GB.UTF-8
> LC_COLLATE="en_GB.UTF-8"
> LC_MONETARY="en_GB.UTF-8"
> LC_MESSAGES="en_GB.UTF-8"
> LC_PAPER="en_GB.UTF-8"
> LC_NAME="en_GB.UTF-8"
> LC_ADDRESS="en_GB.UTF-8"
> LC_TELEPHONE="en_GB.UTF-8"
> LC_MEASUREMENT="en_GB.UTF-8"
> LC_IDENTIFICATION="en_GB.UTF-8"
> LC_ALL=
> $ date +"%l:%M%P"
> 1:39
> $ LC_TIME="POSIX"
> $ date +"%l:%M%P"
> 1:39am
> $
>
> I had a single line of only LANG="en_GB.UTF-8" in /etc/env.d/02locale;
> adding LC_TIME="POSIX" allows various scripts and stuff (I've written) to
> show the date properly, but I think I read somewhere that this is bad.
Your output looks fine, except for the last two commands. LC_TIME is an
envvar, you have set it without exporting it, then ran data again and got a
change. I don't understand how you managed that as LC_TIME would no longer be
POSIX at that stage:
As for the "correct" way and what is "bad", I've also read stuff. I've read
lots and lots and lots of opinions, but not much fact. So here's my own mere
opinion:
It doesn't really matter where you set it as long as it gets the job done.
Put it in conf.d to have it global.
Put it in /etc/profile* to have it global for a shell
Put it in ~/.profile* to set it for a single user.
Or maybe you meant that you've read some people opine that setting just
LC_TIME is bad?
--
alan dot mckinnon at gmail dot com
01-07-2011, 07:21 AM
Steffen Loos
More locale oddness
Am 07.01.2011 02:49, schrieb Stroller:
Hi there,
Can anyone else reproduce this, please, or tell me what behaviour is expected?
On my host it looks the same.
It's based on the definitions in /usr/share/i18n/locales/*.
If you are asking why just have a look on the files there and search for am_pm.
Eg. for en_GB this is the decisive line:
user@host /usr/share/i18n/locales $ grep am_pm en_GB
am_pm "";""
which means: write nothing. And for POSIX:
user@host /usr/share/i18n/locales $ grep am_pm POSIX
am_pm "<U0041><U004D>";"<U0050><U004D>"
which represents "AM;PM" in Unicode.
I had a single line of only LANG="en_GB.UTF-8" in /etc/env.d/02locale; adding LC_TIME="POSIX" allows various scripts and stuff (I've written) to show the date properly, but I think I read somewhere that this is bad.
Hm, it's up to you which locales matches your needs. Maybe a more portable(in sense of locales) timestamp format in your scripts could also be a way.
Steffen
01-07-2011, 03:33 PM
Stroller
More locale oddness
On 7/1/2011, at 6:26am, Alan McKinnon wrote:
>> ...
>> Can anyone else reproduce this, please, or tell me what behaviour is
>> expected?
>>
>> $ locale
>> LANG=en_GB.UTF-8
>> LC_CTYPE="en_GB.UTF-8"
>> LC_NUMERIC="en_GB.UTF-8"
>> ...
>> $ date +"%l:%M%P"
>> 1:39
>> $ LC_TIME="POSIX"
>> $ date +"%l:%M%P"
>> 1:39am
>> $
>
> Your output looks fine, except for the last two commands. LC_TIME is an
> envvar, you have set it without exporting it, then ran data again and got a
> change. I don't understand how you managed that as LC_TIME would no longer be
> POSIX at that stage:
>
> $ cat /etc/env.d/02locale
> LANG="en_GB.utf8"
> $ locale
> LANG=en_GB.utf8
> LC_CTYPE="en_GB.utf8"
> LC_NUMERIC="en_GB.utf8"
> LC_TIME="en_GB.utf8"
> ...
> $ date +"%l:%M%P"
> 8:16
> $ LC_TIME="POSIX"
> $ date +"%l:%M%P"
> 8:17
> $ LC_TIME="POSIX" date +"%l:%M%P"
> 8:18am
I've just tested on another machine. It seems like if I set it to match the first machine with both environments in the /etc/env.d/02locale:
The variable is lacking quotes in the `locale` output above; I have no idea whether or not this makes any difference.
Stroller.
01-08-2011, 12:24 PM
Alan McKinnon
More locale oddness
Apparently, though unproven, at 18:33 on Friday 07 January 2011, Stroller did
opine thusly:
> On 7/1/2011, at 6:26am, Alan McKinnon wrote:
> >> ...
> >> Can anyone else reproduce this, please, or tell me what behaviour is
> >> expected?
> >>
> >> $ locale
> >> LANG=en_GB.UTF-8
> >> LC_CTYPE="en_GB.UTF-8"
> >> LC_NUMERIC="en_GB.UTF-8"
> >> ...
> >> $ date +"%l:%M%P"
> >> 1:39
> >> $ LC_TIME="POSIX"
> >> $ date +"%l:%M%P"
> >> 1:39am
> >> $
> >
> > Your output looks fine, except for the last two commands. LC_TIME is an
> > envvar, you have set it without exporting it, then ran data again and got
> > a change. I don't understand how you managed that as LC_TIME would no
> > longer be POSIX at that stage:
> >
> > $ cat /etc/env.d/02locale
> > LANG="en_GB.utf8"
> > $ locale
> > LANG=en_GB.utf8
> > LC_CTYPE="en_GB.utf8"
> > LC_NUMERIC="en_GB.utf8"
> > LC_TIME="en_GB.utf8"
> > ...
> > $ date +"%l:%M%P"
> > 8:16
> > $ LC_TIME="POSIX"
> > $ date +"%l:%M%P"
> > 8:17
> > $ LC_TIME="POSIX" date +"%l:%M%P"
> > 8:18am
>
> I've just tested on another machine. It seems like if I set it to match the
> first machine with both environments in the /etc/env.d/02locale:
>
> $ cat /etc/env.d/02locale
> LANG="en_GB.UTF-8"
> LC_TIME="POSIX"
> $ sudo env-update && source /etc/profile
> $ source ~/.bashrc
>
> Then I can reproduce switching LC_TIME without exporting or anything else:
>
> $ date +"%l:%M%P"
> 4:01pm
> $ LC_TIME="en_GB.utf8"
> $ date +"%l:%M%P"
> 4:02
> $ LC_TIME="POSIX"
> $ date +"%l:%M%P"
> 4:02pm
> $
>
> Removing either (& rebooting, because I don't really understand this stuff)
> removes the ability.
>
> I don't know whether this is supposed to be correct or not; with both
> environments in /etc/env.d/02locale:
>
> $ LC_TIME="POSIX"
> $ locale
> LANG=en_GB.UTF-8
> LC_CTYPE="en_GB.UTF-8"
> LC_NUMERIC="en_GB.UTF-8"
> LC_TIME=POSIX
> LC_COLLATE="en_GB.UTF-8"
> LC_MONETARY="en_GB.UTF-8"
> LC_MESSAGES="en_GB.UTF-8"
> LC_PAPER="en_GB.UTF-8"
> LC_NAME="en_GB.UTF-8"
> LC_ADDRESS="en_GB.UTF-8"
> LC_TELEPHONE="en_GB.UTF-8"
> LC_MEASUREMENT="en_GB.UTF-8"
> LC_IDENTIFICATION="en_GB.UTF-8"
> LC_ALL=
> $ LC_TIME="en_GB.utf8"
> $ locale
> LANG=en_GB.UTF-8
> LC_CTYPE="en_GB.UTF-8"
> LC_NUMERIC="en_GB.UTF-8"
> LC_TIME=en_GB.utf8
> LC_COLLATE="en_GB.UTF-8"
> LC_MONETARY="en_GB.UTF-8"
> LC_MESSAGES="en_GB.UTF-8"
> LC_PAPER="en_GB.UTF-8"
> LC_NAME="en_GB.UTF-8"
> LC_ADDRESS="en_GB.UTF-8"
> LC_TELEPHONE="en_GB.UTF-8"
> LC_MEASUREMENT="en_GB.UTF-8"
> LC_IDENTIFICATION="en_GB.UTF-8"
> LC_ALL=
> $
>
> The variable is lacking quotes in the `locale` output above; I have no idea
> whether or not this makes any difference.
>
> Stroller.
The effect of LC_TIME= on your machines doesn't make sense to me.
What shell are you running?
--
alan dot mckinnon at gmail dot com
01-08-2011, 01:13 PM
Stroller
More locale oddness
On 8/1/2011, at 1:24pm, Alan McKinnon wrote:
>> ...
>> I've just tested on another machine. It seems like if I set it to match the
>> first machine with both environments in the /etc/env.d/02locale:
>>
>> $ cat /etc/env.d/02locale
>> LANG="en_GB.UTF-8"
>> LC_TIME="POSIX"
>> $ sudo env-update && source /etc/profile
>> $ source ~/.bashrc
>>
>> Then I can reproduce switching LC_TIME without exporting or anything else:
>>
>> $ date +"%l:%M%P"
>> 4:01pm
>> $ LC_TIME="en_GB.utf8"
>> $ date +"%l:%M%P"
>> 4:02
>> $ LC_TIME="POSIX"
>> $ date +"%l:%M%P"
>> 4:02pm
>> $
>>
>> Removing either (& rebooting, because I don't really understand this stuff)
>> removes the ability.
>>
>> I don't know whether this is supposed to be correct or not; with both
>> environments in /etc/env.d/02locale:
>> ...
>
> The effect of LC_TIME= on your machines doesn't make sense to me.
>
> What shell are you running?
Bash.
Stroller.
01-10-2011, 12:48 PM
Steffen Loos
More locale oddness
Am 08.01.2011 14:24, schrieb Alan McKinnon:
Apparently, though unproven, at 18:33 on Friday 07 January 2011, Stroller did
opine thusly:
On 7/1/2011, at 6:26am, Alan McKinnon wrote:
...
Can anyone else reproduce this, please, or tell me what behaviour is
expected?
$ locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
...
$ date +"%l:%M%P"
1:39
$ LC_TIME="POSIX"
$ date +"%l:%M%P"
1:39am
$
Your output looks fine, except for the last two commands. LC_TIME is an
envvar, you have set it without exporting it, then ran data again and got
a change. I don't understand how you managed that as LC_TIME would no
longer be POSIX at that stage:
because: LC_TIME is exported already as it was set via /etc/env.d/02locale.
...
Removing either (& rebooting, because I don't really understand this stuff)
removes the ability.
Only unset LANG and LC_TIME is sufficient to reproduce the behaviour.
The variable is lacking quotes in the `locale` output above; I have no idea
whether or not this makes any difference.