[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bash login script problems...



On Sat, Jun 15, 2002 at 10:16:37PM -0400, Neal Lippman wrote:
| I am having two problems with bash login scripts, which I cannot seem to sort 
| out. Probably something simple, but I'm missing it.
| 
| 1. First, here is a few lines from my .bash_profile. These lines were 
| commented out by default, and I have uncommented them. 

| I have verified, by adding some echo statements, that the body of the if 
| clause IS being executed when I issue './.bash_profile' and so my ~/bin dir 
                                         ^^^^^^^^^^^^^^^

| should be getting added to my path. However, after the script completes, 
| 'echo $PATH' does NOT show any change to my path shell variable.
| 
| What am I missing here?

When you run a script in a subshell, it can modify the environment of
that subshell, then that subshell terminates (when the script is done)
and you get the prompt from your original shell again.  Unlike MS-DOS,
scripts normally run in subshells and can't wreak havoc on your
environment.  If you want to run the script in the current shell, use
one of the following commands :
    . ./.bash_profile
    source ./.bash_profile

| 2. I previously used Mandrake, and just switched to debian. Under KDE, when I 
| run a standard console shell (eg the standard KDE xterm), when I
| used mandrake it appeared that .bash_profile was automatically
| executed, and the suppled mandrake version then executed .bashrc for
| me. It appears that under Debian, however, .bashrc is executed
| directly and .bash_profile is only executed when I login directly on
| a ptty, rather than from an xterm under KDE.

This is normal.  Read 'man bash'.  ~/.bashrc is run for
non-login shells.  ~/.bash_profile is run for login shells.  When you
log in you start a login shell, when you run xterm you don't start a
login shell.

What I do is put all config stuff in ~/.bashrc and ~/.bash_profile
looks like this :


# .bash_profile

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

HTH,
-D

-- 

What good is it for a man to gain the whole world, yet forfeit his
soul?  Or what can a man give in exchange for his soul?
        Mark 8:36-37
 
http://dman.ddts.net/~dman/

Attachment: pgpERrj4va1Ry.pgp
Description: PGP signature


Reply to: