Re: Rereading .bash_profile

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

 



"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

    PATH=${PATH//\/blah\/bin/}
    PATH=${PATH//::/:}:/blah/bin

which guarantees the location of /blah/bin at the end of the PATH.

Most apps need a .+_HOME variable, so the above will become:

    export BLAH_HOME=/usr/local/blah
    PATH=${PATH//${BLAH_HOME}\/bin/}
    PATH=${PATH//::/:}:${BLAH_HOME}/bin


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

  Powered by Linux