Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Help!! Locale disaster - for swedish locales

Hi

I've been mucking about with my system and my locales settings seems to be out of wack. Perldoc doesnt work properly

and trying man pages gets me the following error

Error executing formatting or display command.
System command (cd /usr/share/man && /usr/bin/tbl /usr/share/man/man1/top.1 | /usr/bin/groff -Wall -mtty-char -Tascii -mandoc -c | /usr/bin/less -is) exited with status 256.

these are my locale settings

LANG="sv_SE"
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL="C"

my .bash_profile contains the following

# ~/.bash_profile: executed by bash(1) for login shells.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/login.defs
#umask 022

# the rest of this file is commented out.

# include .bashrc if it exists

if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi

# set PATH so it includes user's private bin if it exists
if [ -d ~/bin ] ; then
PATH=~/bin:"${PATH}"
fi

# do the same with MANPATH
#if [ -d ~/man ]; then
# MANPATH=~/man:"${MANPATH}"
# export MANPATH
#fi

test -r /sw/bin/init.sh && . /sw/bin/init.sh

my bashrc contains the following

PATH=$PATH:/usr/local/bin/:/sw/bin
#alias cdf='cd' "$(~/bin/posd)"'
alias ls='ls -G'
alias mysql=/usr/local/mysql/bin/mysql
alias top='top -Xt -o cpu'

export ENV

my profile contains the following

. /sw/bin/init.sh

export PS1="\w $ "
alias ssh-thomas = "ssh -i ~/.ssh/legolas.id_dsa.pub thomas@teg.pp.se"

# cdf: cd to the directory in the Finder's front window
alias cdf='cd "$(~/bin/posd)"'

# posfind: search the directory frontmost in the Finder
function posfind { find "`~/bin/posd`" -name " $1"; }

# posgrep: grep the directory frontmost in the Finder
function posgrep { grep -iIrn "$1" "`~/bin/posd`"; }

export LANG="sv_SE.utf8"
export LC ALL="svSE.utf8"

what is wrong .... i cry out for help from all command-line buddies 🙂

Pb G4, Mac OS X (10.4.3)

Posted on Nov 19, 2005 10:07 AM

Reply
Question marked as Best reply

Posted on Nov 19, 2005 6:58 PM

Hi Thomas,
Way cool! You're using my posd. Did you get it from Bill Scott, Fink or from a link I posted here? Anyway, I see two problems. First, the ~/.bash_profile and the ~/.profile aren't both sourced at the startup of a login shell. If you're using bash, the bash_profile is the only one that will be sourced so you should have that file source your profile or simply combine the two files.

The more important problem is the value to which you set your LANG and LC_ALL environment variables. I think that it should be:

export LANG="sv_SE.UTF-8"
export LC ALL="svSE.UTF-8"

You should probably double check me on that as I'm doing it from memory. However, I don't think the syntax is flexible so make sure that you get it right. Of course I don't know if that's causing your problem. As I explained in the previous paragraph, the ~/.profile shouldn't be sourced.

Also, could you post the results of the following commands?

type man
type less
file /sw/bin/man
file /usr/bin/man
ls -ld /usr/bin/man
ls -ld /usr/bin/tbl
ls -ld /usr/share/man/man1/top.1
ls -ld /usr/bin/groff
ls -ld /usr/bin/less
fink list man

Also, what happens if you invoke man with an absolute path, /usr/bin/man? I feel confident that we can straighten this out; I have to help out someone which appreciates posd. This is often a locale problem. The usual fix is to set everything to 'C', as you've done. Anyway, we should be able to figure this out.
--
Gary
~~~~
I think a relationship is like a shark. It has to constantly
move forward or it dies. Well, what we have on our hands
here is a dead shark.
-- Woody Allen
9 replies
Question marked as Best reply

Nov 19, 2005 6:58 PM in response to snigelman

Hi Thomas,
Way cool! You're using my posd. Did you get it from Bill Scott, Fink or from a link I posted here? Anyway, I see two problems. First, the ~/.bash_profile and the ~/.profile aren't both sourced at the startup of a login shell. If you're using bash, the bash_profile is the only one that will be sourced so you should have that file source your profile or simply combine the two files.

The more important problem is the value to which you set your LANG and LC_ALL environment variables. I think that it should be:

export LANG="sv_SE.UTF-8"
export LC ALL="svSE.UTF-8"

You should probably double check me on that as I'm doing it from memory. However, I don't think the syntax is flexible so make sure that you get it right. Of course I don't know if that's causing your problem. As I explained in the previous paragraph, the ~/.profile shouldn't be sourced.

Also, could you post the results of the following commands?

type man
type less
file /sw/bin/man
file /usr/bin/man
ls -ld /usr/bin/man
ls -ld /usr/bin/tbl
ls -ld /usr/share/man/man1/top.1
ls -ld /usr/bin/groff
ls -ld /usr/bin/less
fink list man

Also, what happens if you invoke man with an absolute path, /usr/bin/man? I feel confident that we can straighten this out; I have to help out someone which appreciates posd. This is often a locale problem. The usual fix is to set everything to 'C', as you've done. Anyway, we should be able to figure this out.
--
Gary
~~~~
I think a relationship is like a shark. It has to constantly
move forward or it dies. Well, what we have on our hands
here is a dead shark.
-- Woody Allen

Nov 19, 2005 11:24 PM in response to Gary Kerbaugh

Hi

thanks..i believe i got it from one of your postings.

anyway here we go

i'l show the command then the result
type man
/usr/bin/man

type less
/usr/bin/less

file /sw/bin/man
/sw/bin/man: cannot open (/sw/bin/man)

file /usr/bin/man
/usr/bin/man: Mach-O executable ppc

ls -ld /usr/bin/man
-rwxr-xr-x 1 root wheel 50328 21 Mar 2005 /usr/bin/man

ls -ld /usr/bin/tbl
-rwxr-xr-x 1 root wheel 142184 21 Mar 2005 /usr/bin/tbl

ls -ld /usr/share/man/man1/top.1
-r--r--r-- 1 root wheel 12216 21 Mar 2005 /usr/share/man/man1/top.1

ls -ld /usr/bin/groff
-rwxr-xr-x 1 root wheel 97552 21 Mar 2005 /usr/bin/groff

ls -ld /usr/bin/less
-rwxr-xr-x 2 root wheel 118508 21 Mar 2005 /usr/bin/less

fink list man
Information about 1808 packages read in 4 seconds.
compress-zlib-... 1.34-10 Manual pages for compress-zlib-pm
compress-zlib-... 1.34-10 Manual pages for compress-zlib-pm
date-manip-pm 5.40-2 Perl Module to add Date::Manip
funny-manpages 1.3-1 Funny manpages
help2man 1.29-1 Generates man pages from program output
ispell-german 20011124-1 German ispell dictionaries
manconf 20020121-12 Placeholder package for Jaguar update (do not ins...
rman [virtual package]

using an absolute path when invoking man gives the following
/usr/bin/man top
invalid charset name
man: No such file or directory
Failed to open the message catalog man on the path NLSPATH=<none>

Error executing formatting or display command.
System command (cd /usr/share/man && /usr/bin/tbl /usr/share/man/man1/top.1 | /usr/bin/groff -Wall -mtty-char -Tascii -mandoc -c | /usr/bin/less -is) exited with status 256.
No manual entry for top

I made the following changes.
removed .profile

and added its contents to bash_profile which now contains the following
(by the way - yes i am using the bash shell mostly because i have some familiarity with it from linux(debian).

---begin bash_profile -----
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi

if [ -d ~/bin ] ; then
PATH=~/bin:"${PATH}"
fi

test -r /sw/bin/init.sh && . /sw/bin/init.sh

. /sw/bin/init.sh

alias cdf='cd "$(~/bin/posd)"'

function posfind { find "`~/bin/posd`" -name " $1"; }

function posgrep { grep -iIrn "$1" "`~/bin/posd`"; }

export LANG="sv_SE.UTF-8"
export LC ALL="svSE.UTF-8"

---end bash_profile----

By the way..i have had problems with posd too 🙂
but lets leave that out of this and just get the effin locales in order.

and thanks for taking the time

Nov 20, 2005 10:56 AM in response to snigelman

I found some answers.

I apparently had a profile in /etc that acted as a default. I removed any locale settings in that file and then set all my locales as sv_SE and voila perldoc and man pages work again.

However if i try to unset LC_ALL by doing
unset LC_ALL
export LC_ALL

my LC_ALL setting doesnt change. Why is this, and do i need a LC_ALL setting?

Nov 20, 2005 5:43 PM in response to snigelman

Hi Thomas,

> my LC_ALL setting doesnt change.

I can't address that without some information about the circumstances surrounding the commands that set the locale. Are they set in a startup script and if so, which script is it? Did you execute them from the command line? Environment variables are inherited by child processes but no others, so the circumstances are important.

By the way, you provided more information in your posts than almost anyone else here. I just wanted to say that such attention to detail and your awareness of the amount and type of information necessary to diagnose a computer problem are impressive and greatly appreciated. I'm sure that the effort you put into composing good questions did more to help you find the answer than anything I said.

Naturally I'm thrilled that you solved the original problem. Whenever you want to address the issues you're having with posd, just let me know. It doesn't matter to me whether it's this thread or a new one.
--
Gary
~~~~
Warp 7 -- It's a law we can live with.

Nov 21, 2005 11:26 AM in response to Gary Kerbaugh

Hi Gary,

thanks for the comments. As it turned out my last claim was somewhat incorrect, i did manage to change my locale setting which are now as follows

LANG="sv_SE"
LC COLLATE="svSE.UTF-8"
LC CTYPE="svSE"
LC MESSAGES="svSE"
LC MONETARY="svSE"
LC NUMERIC="svSE"
LC TIME="svSE"
LC ALL="sv_SE.UTF-8/sv_SE/sv_SE/sv_SE/sv_SE/svSE"

when i test out my different locale choices i do so using set respective unset LC_CTYPE=whatever and do export LC_CTYPE at the command prompt (no sudo) -is there another way?

This doesnt always change the locale, particularly with respect to the LC_ALL command.

The other way i make changes is by entering a setting in .bash_profile which these days contains - with respect to locale - the following

export LANG="sv_SE"
export LC CTYPE="svSE"
export LC COLLATE="svSE.UTF-8"

when i put in LC COLLATE="svSE.UTF-8" my LC_ALL turned into the weird line i now have, i.e LC ALL="sv_SE.UTF-8/sv_SE/sv_SE/sv_SE/sv_SE/svSE"

I should say that everything seems to be working ok.

I will admit i am a bit non-plussed about locales and how they are set. I realize that if i initiate an interactive terminal the my locales seem to come from .bash_profile as things stand. What if i execute a perl script as say user dillo via a cron script that runs.. where will that perl script find locales or for that matter if i run a bash script the same way? If your systems runs a script - not using a login terminal then where do the locales come from on a macos-x machine? And where are the gui locales set? I thought there was supposed to be an environment.plist on the machine bit I sure as heck cant find one.

A note..perldoc perllocale says the following

The comparison operators ("lt", "le", "cmp", "ge", and "gt") and
the POSIX string collation functions strcoll() and strxfrm() use
"LC_COLLATE". sort() is also affected if used without an explicit
comparison function, because it uses "cmp" by default.

which is why i tried setting the LC_COLLATE to sv_SE.UTF-8

anyway..i'm rambling almost. 🙂

If you know your way about locales i'd really appreciate a short run down on how locales are set and applied and - as a cherry on top - which different locale variables should be set. As far as I understand one should be able to have different locales on different values...which ofcourse makes me wonder..when I have just sv_SE set what exactly do i have..is iso-8859-1 or is it utf-8 or what? can i check that somehow.

Ah, Gary, i'll stop there 🙂. If you answer all of that then great, if you just want to take stab at one or two things thats also great..and if i've just talked your ears off then well..i'll be careful where i put my foot. 🙂

Thomas

Nov 21, 2005 5:05 PM in response to snigelman

Hi Thomas,
I'm hardly an expert on locales. Mine is en_US.UTF-8 so I don't need to know much. All I know is what's in the locale man page, the format of the values and I know the UTF-8 spec. However, knowing that spec means that I think it would be silly to use any other encoding unless forced. Since you want the same country and language for all values, I really don't see why you don't set LC_ALL to sv_SE.UTF-8 and be done with it. That sets all of the others to the same as implied values; that's what it's there for. You should read the locale man page.

As for setting the variables, it sounds like you want to only use "export" in the scripts. It is the "export" command that identifies a variable to the shell as an environment variable. It can be used anywhere that shell input is allow, such as in script and in the command line. Using "export" means that the shell creates a variable by that name in the namespace of every process that is an offspring of the one in which the export command is used. (definition of "environment") Thus, the use of the "export" command determines the environment of processes launched from within a shell.

Cron jobs are different and have their own environment. If you want to set the environment of a process launched by cron, that may have to be done differently. In fact, if you have Tiger, by default you use launchd instead of cron. You can also launch cron with launchd. In those cases, you can set environment variable as values in the dict of the EnvironmentVariables key in the property list of the process being launched. Otherwise you can set variables in the Perl script itself or you can wrap the invocation of the perl script in shell script that sets the environment first. Again, some details would make discussion easier.

You are correct that you can use an environment.plist but you have to create it. It won't apply to cron jobs other than yours but it will apply to all of your processes and is thus very useful. That is discussed at length in Using ~/.MacOSX/environment.plist to set environment variables, Runtime Configuration Guidelines: Environment Variables and Using ~/.MacOSX/environment.plist.
--
Gary
~~~~
standards, n.:
The principles we use to reject other people's code.

Nov 22, 2005 11:03 AM in response to Jun T.

Hi

i did a ls -l on /usr/share/locale/

i was a bit surprised what i found out

here are the results for sv_SE

lrwxr-xr-x 1 root wheel 28 31 Maj 16:35 LC_COLLATE -> ../la LN.US-ASCII/LCCOLLATE
lrwxr-xr-x 1 root wheel 17 31 Maj 16:35 LC_CTYPE -> ../UTF-8/LC_CTYPE
drwxr-xr-x 3 root wheel 102 31 Maj 16:35 LC_MESSAGES
lrwxr-xr-x 1 root wheel 30 31 Maj 16:35 LC_MONETARY -> ../sv SE.ISO8859-1/LCMONETARY
lrwxr-xr-x 1 root wheel 29 31 Maj 16:35 LC_NUMERIC -> ../sv SE.ISO8859-1/LCNUMERIC
-r--r--r-- 1 root wheel 376 21 Mar 2005 LC_TIME

and here are the results for sv_SE.UTF-8

lrwxr-xr-x 1 root wheel 28 31 Maj 16:35 LC_COLLATE -> ../la LN.US-ASCII/LCCOLLATE
lrwxr-xr-x 1 root wheel 17 31 Maj 16:35 LC_CTYPE -> ../UTF-8/LC_CTYPE
drwxr-xr-x 3 root wheel 102 31 Maj 16:35 LC_MESSAGES
lrwxr-xr-x 1 root wheel 30 31 Maj 16:35 LC_MONETARY -> ../sv SE.ISO8859-1/LCMONETARY
lrwxr-xr-x 1 root wheel 29 31 Maj 16:35 LC_NUMERIC -> ../sv SE.ISO8859-1/LCNUMERIC
-r--r--r-- 1 root wheel 376 21 Mar 2005 LC_TIME

What surprised me is that LC_COLLATE is a link to US_ASCII

ah well..what the heck..thinsg work now..but still thanks for the help much appreciated.

Thomas

Help!! Locale disaster - for swedish locales

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.