Rereading .bash_profile

Nifty Hat Mitch mitch48 at sbcglobal.net
Wed Oct 27 05:55:01 UTC 2004


On Mon, Oct 25, 2004 at 05:36:29PM -0400, Lew Bloch wrote:
> "Robert P. J. Day" wisely reminded us:
> >a classic example is to append some entries to your search path:
> >
> >  PATH=$PATH:blah:woof:.....
> >
> >rerunning .bash_profile means that those entries will be appended
> >*again*.  not fatal, of course, but i think too many people very
> >cavalierly re-source that file without making sure there are no
> >adverse consequences.
> 
> With care you can ensure that your .bash_profile actions are idempotent 
> - they leave the same result state as the first time every time.
> 
> For example:
> 
>     if [ "${PATH/\/blah\/bin/}" = "${PATH}" ]
>     then
> 	PATH=${PATH}:/blah/bin
>     fi
> 
> which might leave /blah/bin in the PATH at some position not the end, or
......

Very good advice.

In general such tinkering should be done
with a $HOME/.my-project file.

The .bash_profile file can have a line

    . $HOME/.my-project-X

This line can be commented out while you are working on it.

You can always type the same command while you are testing as well.

    . $HOME/.my-project-X

The value of this is that it isolates the changes and sets the 
stage for a more tidy user home.  It also permits moving the function
to a system file.... See all the other equivalent files.

     /etc/profile.d/*.sh


-- 
	T o m  M i t c h e l l 
	May your cup runneth over with goodness and mercy
	and may your buffers never overflow.




More information about the fedora-list mailing list