LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-02-2004, 01:24 PM   #1
Bralkein
LQ Newbie
 
Registered: Mar 2004
Location: England
Distribution: Slackware
Posts: 6

Rep: Reputation: 0
Setting environ. variables before bash starts at login


Okay, here is my problem, if anyone can help, then thanks a lot in advance!

I have just made a basic Linux From Scratch system (probably not a good idea when you've only used Linux for a few months, but hey, you've got to learn somehow!), and I have this problem. I have asked people on the LFS IRC channel and they did not seem to know, so I am asking here instead, it does not seem like a very LFS-specific problem, so I reckon someone should be able to help me!

I live in England, and as such, I have an English keyboard. When I compiled my kernel, I made sure that I had set the keymap in the kernel source as the UK one (uk.map.gz). I also have a loadkeys init script, just to be doubly sure that the proper keymap is loaded when I boot up. This works fine with VIM and such; I can do SHIFT-3 and the sign comes up like that. But after I log on and bash starts up, if I press SHIFT-3, then the # sign appears on the command prompt.

After some research, I discovered that this was because the locale settings were not right. If I type in "locale" at the bash prompt on my SuSE installation, I get the following:

LANG=en_GB
LC_CTYPE="en_GB"
LC_NUMERIC="en_GB"
LC... et cetera.

This is good, because I can type the sign and everything! However, if I am on my Linux From Scratch system, I can type in "locale" at the prompt and instead I get this:

LANG=POSIX
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC... et cetera.

Which I am sure is all very standards-compliant and everything, but I want my symbol! So far, I have tried the following things to fix this:

- Exporting LANG=en_GB at boot in an init script

This did not work. I think that login resets all the environment variables, so LANG and everything all stays as POSIX.

- Exporting LANG=en_GB in bash's /etc/profile

This worked a bit. if you do things this way, you can type in "locale" and it says that it is all en_GB, but if you do SHIFT-3 then you still only get the # character. If you type "bash" in at the prompt though, then you get another instance of the shell, which will show the symbol when you do SHIFT-3.

- Setting my default shell to a script

In the /etc/passwd file, I set my user's default shell to a script called startbash, which I just shoved in /bin (so I set it to /bin/startbash). This is the script I wrote:

#!/bin/bash
export LANG=en_GB
/bin/bash

And okay, okay, this did actually work! I could log on and get my beloved symbol, and the ? symbol was on the right key and everything. But basically this method screams "SHODDY HACK" and I would like to ditch it ASAP. Anyone got any ideas? Thanks in advance!
 
Old 03-02-2004, 05:39 PM   #2
Bralkein
LQ Newbie
 
Registered: Mar 2004
Location: England
Distribution: Slackware
Posts: 6

Original Poster
Rep: Reputation: 0
Exclamation Doh!

Okay, this is going to sound dumb now, but I solved the problem. After reading through the files in /etc, I got to login.defs and it turns out that you can set an option to use a file with environment variables in to start the terminal with. The default file it reads from is /etc/environment, but I think you can change it. I put LANG=en_GB in there and now everything works as it should. Whoops!

Oh well, maybe a moderator could see their way to moving this to success stories now or something
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting Bash Variables from outside data file llewis Programming 10 01-12-2005 04:30 AM
bash variables pfaendtner Linux - Newbie 4 11-23-2004 01:00 PM
strange behaviour when bash starts Y0jiMb0 Linux - General 8 07-09-2004 06:29 AM
Bash variables pk21 Programming 2 01-09-2003 03:31 PM
setting the environ albean Linux - Newbie 1 10-06-2002 09:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration