updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / jre5-opt / usejava.sh
blobe2dc4449e27a96041df7bcea44211ee86cc053e3
1 # switch PATH to new JAVA_HOME
3 path_remove() {
4 # remove element from colon separated list
5 # usage: path_remove <pathvar> <pathelement>
6 eval path_removeP="\"\$$1\""
7 path_removeP=`(NP= S= IFS=: ; for P in $path_removeP; do [ "$P" = "$2" ] && continue; NP="$NP$S$P"; S=':'; done; echo "$NP")`
8 eval $1='"$path_removeP"'
9 eval [ "\"\$$1\"" ] || unset "$1"
12 path_remove PATH "/opt/java/jre/bin"
13 path_remove PATH "/opt/java/bin"
14 path_remove PATH "/opt/java5/jre/bin"
15 path_remove PATH "/opt/java5/bin"
17 if [ "$JAVA_HOME" ]; then
18 path_remove PATH "$JAVA_HOME/bin"
19 path_remove PATH "$JAVA_HOME/jre/bin"
20 PATH=$JAVA_HOME/jre/bin:$PATH
22 [ -f "$JAVA_HOME/bin/java" ] || JAVA_HOME=$JAVA_HOME/jre # if jdk not installed
25 export JAVA_HOME
27 unset -f path_remove