.bashrc .profile .bash_profile
Scott Haneda
talklists at newgeo.com
Thu Oct 1 14:41:05 PDT 2009
I need to understand this once and for all, there is varying info on
this, the bash man page is verbose and not entirely clear.
When bash is invoked as an interactive login shell, or as a
non-inter-
active shell with the --login option, it first reads and
executes com-
mands from the file /etc/profile, if that file exists.
After reading
that file, it looks for ~/.bash_profile, ~/.bash_login, and
~/.profile,
in that order, and reads and executes commands from the first
one that
exists and is readable. The --noprofile option may be used
when the
shell is started to inhibit this behavior.
This implies, that only one of those files is read. That it stops
once it finds one. I have:
.bash_profile, .bashrc, and .profile
The .profile, macports suggested I make, or maybe made it.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
What is the suggested way to deal with these files?
I have .bashrc with some aliases, history control, ls colors, and
apparently some PATH exports for macports.
When an interactive shell that is not a login shell is
started, bash reads and
executes commands from ~/.bashrc, if that file exists. This
may be inhibited by
using the --norc option. The --rcfile file option will
force bash to read and
execute commands from file instead of ~/.bashrc.
I am pretty sure I need to stop using .bashrc, since that is for
interactive non login shells, which I am interpreting as shells that
do work that is not the result of me using the shell. So, if I were
to alias rm to mv for example, and some app called rm, in reality, it
would mv the file. I want to prevent stepping on the assumptions of
other apps, correct?
I think I even went to extra effort to make this happen as
my .bash_profile:
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
Sounds to me, like the correct course of action is to put my custom
shell aliases and settings in ~/.bash_profile, that will get read on
start, but then no further reading is done. I then need to
source .profile which is the file that MacPorts reads.
This brings up a question, if the .bash* files do not cascade, and
stop after finding your local one, how is it that MacPorts suggests to
use .profile, as that will never get read?
Any suggestions on how to be clean about this, I would love to know,
this has bothered me for ages.
On a side note, I am doing this:
export LSCOLORS=dxfxcxdxbxegedabagacad
Which has never worked for me on a non darwin OS. Is that the wrong
way to do it, are there more appropriate ways to do coloring? I think
having this in .bashrc actually hurt me ones, as MacPorts saw either:
export CLICOLOR=1 or export CLICOLOR_FORCE=1
and did not like it for some reason, that was here http://archive.netbsd.se/?ml=macports-dev&a=2009-05&t=10790101
but I do not seem to recall whether I solved it or just removed the
setting temporarily.
I know this is a smidge off topic, but MacPorts does suggest to use
a .profile, and I hope you guys can help me figure out the correct
usage. Bash man pages imply the first user file is read, then no more
reading is done.
Thank you
--
Scott * If you contact me off list replace talklists@ with scott@ *
More information about the macports-users
mailing list