From 7591cab6064fbd3281afc069d4fb4d8b5a3d8202 Mon Sep 17 00:00:00 2001 From: Marcel Loose <loose@astron.nl> Date: Fri, 8 Apr 2005 10:54:46 +0000 Subject: [PATCH] %[ER: 253]% Added check for valid $a_root. Fixed bug when cd is an alias. --- LCS/Tools/src/lofarinit.csh | 55 +++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/LCS/Tools/src/lofarinit.csh b/LCS/Tools/src/lofarinit.csh index ab10e9e3352..de0f08bb124 100644 --- a/LCS/Tools/src/lofarinit.csh +++ b/LCS/Tools/src/lofarinit.csh @@ -28,34 +28,41 @@ # The actual value is filled in by make install (see Makefile.am). set a_root = . #filled in by install -# First strip the current LOFARROOT from PATH and LD_LIBRARY_PATH -# Take care that a possible . is preceeded by a backslash. -if ($?LOFARROOT) then +# Only modify path variables if $a_root is an existing directory. +if (! (-d $a_root) ) then + echo "LOFAR root directory $a_root does not exist" +else + # First strip the current LOFARROOT from PATH and LD_LIBRARY_PATH + # Take care that a possible . is preceeded by a backslash. + if ($?LOFARROOT) then + set a_path = `echo $LOFARROOT | sed -e 's/\./\\\./g'` + set a_bin = "$a_path/bin" + setenv PATH `echo $PATH | sed -e "s%:${a_bin}:%:%g" -e "s%^${a_bin}:%%" -e "s%:${a_bin}"'$%%' -e "s%^${a_bin}"'$%%'` + set a_lib = "$a_path/lib" + setenv LD_LIBRARY_PATH `echo $LD_LIBRARY_PATH | sed -e "s%:${a_lib}:%:%g" -e "s%^${a_lib}:%%" -e "s%:${a_lib}"'$%%' -e "s%^${a_lib}"'$%%'` + endif + + # Now define the new LOFARROOT + setenv LOFARROOT `cd >/dev/null $a_root; pwd` # make path absolute + + # Also strip this path from the current paths (in case it is contained in + # it). set a_path = `echo $LOFARROOT | sed -e 's/\./\\\./g'` set a_bin = "$a_path/bin" setenv PATH `echo $PATH | sed -e "s%:${a_bin}:%:%g" -e "s%^${a_bin}:%%" -e "s%:${a_bin}"'$%%' -e "s%^${a_bin}"'$%%'` set a_lib = "$a_path/lib" setenv LD_LIBRARY_PATH `echo $LD_LIBRARY_PATH | sed -e "s%:${a_lib}:%:%g" -e "s%^${a_lib}:%%" -e "s%:${a_lib}"'$%%' -e "s%^${a_lib}"'$%%'` -endif - -# Now define the new LOFARROOT -setenv LOFARROOT `cd $a_root; pwd` # make path absolute + + # Add the path to the standard paths. + if (! $?PATH) then + setenv PATH $LOFARROOT/bin + else + setenv PATH $LOFARROOT/bin:$PATH + endif + if (! $?LD_LIBRARY_PATH) then + setenv LD_LIBRARY_PATH $LOFARROOT/lib + else + setenv LD_LIBRARY_PATH $LOFARROOT/lib:$LD_LIBRARY_PATH + endif -# Also strip this path from the current paths (in case it is contained in it). -set a_path = `echo $LOFARROOT | sed -e 's/\./\\\./g'` -set a_bin = "$a_path/bin" -setenv PATH `echo $PATH | sed -e "s%:${a_bin}:%:%g" -e "s%^${a_bin}:%%" -e "s%:${a_bin}"'$%%' -e "s%^${a_bin}"'$%%'` -set a_lib = "$a_path/lib" -setenv LD_LIBRARY_PATH `echo $LD_LIBRARY_PATH | sed -e "s%:${a_lib}:%:%g" -e "s%^${a_lib}:%%" -e "s%:${a_lib}"'$%%' -e "s%^${a_lib}"'$%%'` - -# Add the path to the standard paths. -if (! $?PATH) then - setenv PATH $LOFARROOT/bin -else - setenv PATH $LOFARROOT/bin:$PATH -endif -if (! $?LD_LIBRARY_PATH) then - setenv LD_LIBRARY_PATH $LOFARROOT/lib -else - setenv LD_LIBRARY_PATH $LOFARROOT/lib:$LD_LIBRARY_PATH endif -- GitLab