Re: Add to $PATH how?

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

 



On Monday, Jun 5th 2006 at 18:37 +0100, quoth Timothy Murphy:

=>Paul Howarth wrote:
=>
=>>> It's not really clear to me what one would use . bashrc for;
=>>> it seems everything should go in .bash_profile .
=>> 
=>> No. The key point is that *either* .bash_profile (for login shells)
=>> *or* .bashrc (other shells) is run, not both. See the INVOCATION section
=>> of "man bash". Typically you would set things that are inherited by
=>> subshells (e.g. environment variables) in .bash_profile, and things that
=>> need to be set up in each shell (e.g. aliases) in .bashrc.
=>
=>OK, thanks, I am beginning to see the light.
=>
=>So I will put aliases in .bashrc .
=>But is there anything else that should go there?
=>
=>I did look at "man bash" but found it rather dense.
=>
=>Am I right in thinking that bash is normally run in 3 ways:
=>
=>(1) The login program invokes bash as a "login shell",
=>as also does ssh;

Be aware that ssh starts a login shell except if you are running a 
specific command. e.g., ssh foo is a login shell, but ssh foo pwd is not. 
So the correct thing to do is to set your PATH in you .bash_profile and to 
also set it in your .bashrc IF YOU ARE NOT INTERACTIVE. Test if you're 
interactive in your .bashrc by looking if $PS1 is null.

if [[ -z "$PS1" ]]
then
	# Set aliases here
else
	# Set PATH here
fi

=>
=>(2) xterm, konsole, etc, invoke bash as an "interactive shell";
=>
=>(3) shell scripts invoke bash as a "non-interactive shell"?

.bashrc is not sucked in for shell scripts but it is for an interactive 
subshell like (2) above. (obscurata) If you really want .bashrc to be read 
when starting a script then just set the BASH_ENV env var to ~/.bashrc

-- 
steveo at syslang dot net TMMP1 http://frambors.syslang.net/
Do you have neighbors who are not frambors?


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux