su - user -c sets locale variables to "POSIX"
I need to run SBCL in a UTF-8 environment in a VM running Arch. When I log in as the dedicated user and run the start script, it runs in UTF-8 and works fine. However I need to start it through a (bash) script, and when I run it with:
su - user -c /var/lib/.../start-script
it runs in an environment with all language variables set to POSIX, which causes errors.
I have set LOCALE to en_US.UTF-8 in rc.conf and checked locale.gen, and both the root and the user use this normally. Running locale as root shows all variables set properly to en_US.UTF-8.
Yet when I do su - user -c locale, it's all set to POSIX.
How is this possible, who is this user su runs as, what should I do?
EDIT: It works if I do:
su - user -c export LANG=en_US.UTF-8 && /var/lib/.../start-script
I don't understand why this is required.
EDIT: I read about some update late last year, which made /etc/profile.d/locale.sh obsolete (?) and made /etc/locale.conf take precedence over /etc/rc.conf. Following those instructions isn't working for me though. Moving locale.sh and using /etc/locale.conf sets all vars to POSIX for all users; if I keep it it's still the same as I originally described.
Try it with "su" instead of "su -". The dash causes su to load the users's environment instead of using what you already have.
So omitting the hyphen makes it use the root's environment? It might kind of work since root does use unicode, but optimally I *want* su to load that user's environment, and that's not what it does with "su -". The user also has all locale variables set to unicode.
What I want to do is to run the process as that user, in that user's environment, from a bash script at boot time.
Where is the user getting the LANG setting?
Sorry for the delay, celebrated the Chinese New Year...
I only have LOCALE=en_US.UTF-8 in /etc/rc.conf, and don't set any locale variables manually anywhere else, for any user... And it works everywhere except this
Someone mentioned that perhaps su - user clears all environment settings, that would make more sense with these results.
|All times are GMT -5. The time now is 05:55 AM.|