FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 01-07-2011, 01:29 AM
Dale
 
Default More locale oddness

Stroller wrote:

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.

Thanks for any advice,

Stroller.




This is mine:

root@fireball / # locale
LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
root@fireball / #

No idea about anything bad tho. Just for comparison.

Dale

:-) :-)
 
Old 01-07-2011, 05:26 AM
Alan McKinnon
 
Default 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:

$ 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"
LC_COLLATE="en_GB.utf8"
LC_MONETARY="en_GB.utf8"
LC_MESSAGES="en_GB.utf8"
LC_PAPER="en_GB.utf8"
LC_NAME="en_GB.utf8"
LC_ADDRESS="en_GB.utf8"
LC_TELEPHONE="en_GB.utf8"
LC_MEASUREMENT="en_GB.utf8"
LC_IDENTIFICATION="en_GB.utf8"
LC_ALL=
$ date +"%l:%M%P"
8:16
$ LC_TIME="POSIX"
$ date +"%l:%M%P"
8:17
$ LC_TIME="POSIX" date +"%l:%M%P"
8:18am


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
 
Old 01-07-2011, 07:21 AM
Steffen Loos
 
Default 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?

$ 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
$

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
 
Old 01-07-2011, 03:33 PM
Stroller
 
Default 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:

$ 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.
 
Old 01-08-2011, 12:24 PM
Alan McKinnon
 
Default 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
 
Old 01-08-2011, 01:13 PM
Stroller
 
Default 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.
 
Old 01-10-2011, 12:48 PM
Steffen Loos
 
Default 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.

I think it doesn't.

Steffen
 

Thread Tools




All times are GMT. The time now is 07:23 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org