LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   $PATH duplicate set issue (https://www.linuxquestions.org/questions/linux-newbie-8/%24path-duplicate-set-issue-332314/)

apocolpse 06-10-2005 05:50 PM

$PATH duplicate set issue
 
This is a small issue but it has been boggling my mind for some time now. I'm running fedora core 3, gnome 2.8. When i echo my path i get /usr/lib/java-1.5.0/bin:/usr/lib/jvm/bin:/usr/kerberos/bin:/usr/lib/java-1.5.0/bin:/usr/lib/jvm/bin:.... etc

if you notice i have my java VM and SDK set twice :confused: When i initially setup thhe jdk i work this script

# JRE SETTINGS
export J2RE_HOME=/usr/lib/jvm
export PATH=$J2RE_HOME/bin:$PATH

#JDK SETTINGS
export JDK_HOME=/usr/lib/java-1.5.0
export PATH=$JDK_HOME/bin:$PATH

As far as i can see i only set the path once for each. I've been searching all over and cant seem to find out why this is. Can someone please help me ???

Komakino 06-10-2005 05:59 PM

What's the rest of that section of your /etc/profile (or .bashrc) file look like?

apocolpse 06-10-2005 06:18 PM

The script I wrote is in /etc/profile.d. The name of the file is java.sh. The /etc/profile file is below

# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}

# Path manipulation
if [ `id -u` = 0 ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi

pathmunge /usr/X11R6/bin after


# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"

HOSTNAME=`/bin/hostname`
HISTSIZE=1000

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
INPUTRC=/etc/inputrc
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done

unset i
unset pathmunge

foo_bar_foo 06-10-2005 10:54 PM

you just have to follow the paper trail on this one
and ask yourself a few questions and be a script detective

1) what do each of the scripts in /etc/profile.d do ?
2) are there any other scripts that run automatically that are calling all the scripts in /etc/profile.d
or simply rerunning /etc/profile like /etc/bashrc ~/.bash_profile ~/.bashrc
or have you put the code in more than one place
3) i like the function name "pathmunge" are any other of the scripts "munging" with something like
Code:

for directory in $(find /usr/lib/*/bin -type d 2>/dev/null); do
        pathmunge $directory


Komakino 06-11-2005 05:35 AM

and if you post code PLEASE put it between [ code ] and [/ code ] brackets!


All times are GMT -5. The time now is 06:48 AM.