I have a program I've been using for years that I really like called
envv. I put it up at http://logsoft.com/steveo/envv-1.2p4.tar.gz It's
nice. It's written in C, has a man page and it works well.

The way it works is that I set my PATH variable in a seperate file
called ~/.bash_path

As you can see, envv takes a command, like add or delete, and a
directory path and a possible position. Then it produces as output a
string that if executed will set your PATH variable the way you want
it.

Just make sure that your default PATH is enough to locate where envv is.

# System wide bash_path file. This is used to set up the global PATH variable.
function i_check_exist()
{
    if [[ -d $1 ]]
    then
        eval `envv add PATH $1 $2`
    fi
}

sav=$SHELL
export SHELL=/bin/bash
i_check_exist . 1               # Put it first.
i_check_exist ~/bin 2           # Put it first.
i_check_exist /usr/games        # Put it last.
i_check_exist /usr/local/office52       # Put it last.
i_check_exist /usr/local/jdk/jdk1.2/bin # Put it last.
SHELL=${sav}
unset i_check_exist sav

# Local Variables:
# mode: shell-script
# End:


-- 
-Time flies like the wind. Fruit flies like a banana. [EMAIL PROTECTED]
-Stranger things have happened but none stranger than this. Steven W. Orr-
Does your driver's license say Organ Donor?Black holes are where God \
-------divided by zero. Listen to me! We are all individuals!---------

On Sun, 7 May 2000, rpjday wrote:

=>On Sun, 7 May 2000, Bruce A. Mallett wrote:
=>
=>> While on the PATH manipulation subject, I find the following function
=>> handy when using ksh.  It eliminates duplicates in a PATH style string.
=>> This is useful when one has a lot of things like:
=>> 
=>>    export PATH="$PATH;/some/new/stuff"
=>> 
=>> These tend to accumulate a lot of duplicate entries which can be eliminated
=>> using this function by:
=>> 
=>>    RemoveDups "$PATH"
=>>    export PATH="$_RemoveDups"
=>
=>i'm nervous about the technique of returning arbitrary values from
=>functions by assigning those values to a global variable.  an
=>alternative technique is to have the function return the value
=>by printing it, and getting that value using command substitution:
=>
=>PATH=$(RemoveDups $PATH)
=>
=>  the RemoveDups function itself would then, as the last statement,
=>simply
=>
=>print <new path>
=>
=>  comments?
=>
=>rday
=>
=>------------------------------
=>


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to