2

To support an application we just installed, I've been asked to add this command to the /etc/profile file on our Solaris 10 UNIX server:

LC_ALL=en_US.UTF-8; export LC_ALL

The effect of this changes the "locale" on the server, which is currently not defined (defaulting to "C").

My question: is there any reason I should not make this change?

As an alternative, I can imagine writing a script that exports that variable, runs the application and then "unsets" it again. I don't mind doing that but I really don't know very much about the impact of making a change like this.

I also understand that the same change can be made to the /etc/default/init file. Would that be a better solution?

migrated from stackoverflow.com Aug 29 '13 at 21:33

This question came from our site for professional and enthusiast programmers.

1

LC_ALL trumps all other environment settings. I strongly recommend not setting this system-wide, because it means that any application or user that wants to use different settings must first unset LC_ALL.

Instead, if one application needs specific locale settings, run it through a wrapper script.

#!/bin/sh
LC_ALL=en_US.UTF-8 exec /path/to/application "$@"
1

UTF-8 is quite a better choice than the POSIX locale and is actually now the default Solaris 11 codeset.

I wouldn't expect anything wrong using it as it is fully upward compatible with ASCII.

As for en_US, there will be subtle differences like the character ordering or the way dates are displayed like exhibited in these commands:

$ export LC_ALL=C
$ date
Wed Aug 28 01:21:55 CEST 2013
$ printf "a\nb\nA\nB\nC\n" | sort
A
B
C
a
b
$ LC_ALL=en_US.UTF-8
$ date
Wednesday, August 28, 2013 01:21:58 AM CEST
$ printf "a\nb\nA\nB\nC\n" | sort
a
A
b
B
C

This won't affect system software as of course all provided locales are supported.

Applications that do require a strict POSIX behavior should set LC_ALL to C or POSIX.

As for where to implement the change, the better way is by editing the /etc/default/init file which will set every process default locale and not only sh, ksh, bash and zsh.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.