On Apr 14, 2007, at 7:54 AM, McKown, John wrote:
-----Original Message-----
From: Linux on 390 Port [mailto:[EMAIL PROTECTED] On
Behalf Of Leland Lucius
Sent: Friday, April 13, 2007 4:17 PM
To: [EMAIL PROTECTED]
Subject: Re: How to replace a "entry" in PATH?
Quoting "McKown, John" <[EMAIL PROTECTED]>:
#!/bin/sh
newhome="/java160"
if [ ! -z "$JAVA_HOME" ]; then
PATH=$(echo "$PATH" | sed -e "s#$JAVA_HOME/bin##g;s/::/:/g")
fi
export JAVA_HOME=${newhome}
export PATH="$PATH:$JAVA_HOME/bin"
Will this work for ya?
Leland
That looks promising. I would think that the # symbol is not likely to
occur in a directory name.
I've been thinking about how I would solve this problem since the
original request came through the list. The solutions offered in the
meantime will work, but to me they have felt a lot like "gee whiz,
look what I can do!" They haven't felt very practical, nor
particularly maintainable.
I think, in a production enterprise environment, I'd export a
variable in .profile or .login, say $MPATH, which contained whatever
path I wanted, save for the path to $JAVA_HOME, and then update the
user process documentation saying so (assuming I intended to deploy
this for users other than myself). Example:
MPATH=${PATH}:~/bin ; export MPATH
PATH=${MPATH} ; export PATH
Then, I'd rebuild my $PATH as required with the correct $JAVA_HOME,
either in front or behind, as appropriate.
PATH=${JAVA_HOME}/bin:${MPATH} ; export PATH
When I needed to change it:
JAVA_HOME=~/elbow/jdk9 ; export JAVA_HOME
PATH=${MPATH}:${JAVA_HOME}/bin ; export PATH
Basic, but sufficient in most cases, I should imagine.
ok
bear
----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390