I am creating a script to configure and launch software. My current application requires appending to LD_LIBRARY_PATH. I know that I can test if this is empty first and set it outright and append it otherwise.
The following does not appear to work and it keeps appending to the variable even if it contains the string I am testing for in the case statement.
mysetup.sh
export AXIS2C_HOME=/home/ojblass/Source/axis2c-src-1.6.0
if [ "$LD_LIBRARY_PATH" == "" ]; then
echo empty setting
export LD_LIBRARY_PATH=${AXIS2C_HOME}/lib
else
case $LD_LIB_PATH in
*$AXIS2C_HOME/lib* )
echo already there skipping;;
* )
echo has entries but appending
export LD_LIBRARY_PATH=${AXIS2C_HOME}/lib:${LD_LIBRARY_PATH};;
esac
fi
echo AXIS2C_HOME=${AXIS2C_HOME}
echo LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
Example_Run
ojblass@helium:~/Source/axis2c-src-1.6.0$ pwd /home/ojblass/Source/axis2c-src-1.6.0 ojblass@helium:~/Source/axis2c-src-1.6.0$ . ./mysetup.sh empty setting AXIS2C_HOME=/home/ojblass/Source/axis2c-src-1.6.0 LD_LIBRARY_PATH=/home/ojblass/Source/axis2c-src-1.6.0/lib ojblass@helium:~/Source/axis2c-src-1.6.0$ . ./mysetup.sh has entries but appending AXIS2C_HOME=/home/ojblass/Source/axis2c-src-1.6.0 LD_LIBRARY_PATH=/home/ojblass/Source/axis2c-src-1.6.0/lib:/home/ojblass/Source/axis2c-src-1.6.0/lib
As you notice the LD_LIBRARY_PATH keeps getting added to. Also I am a bit fearful of being shell specific and not being as portable as I would like. Any advice is appreciated.