etc/bashrc tweak to cleanse env vars, even from a different WM_PROJECT_INST_DIR

- Problem: changing between OpenFOAM versions with different
  WM_PROJECT_INST_DIR paths would leave the old paths in the env vars.

- TODO: etc/cshrc is rougned out, but needs work on the corresponding
  if-statement
This commit is contained in:
Mark Olesen
2009-01-08 22:34:54 +01:00
parent e255f36114
commit 7f8e6e6077
2 changed files with 58 additions and 39 deletions

View File

@ -35,7 +35,9 @@ setenv WM_PROJECT OpenFOAM
# setenv WM_PROJECT_VERSION 1.5.x
if ( ! $?WM_PROJECT_VERSION ) setenv WM_PROJECT_VERSION dev
#!!User:
################################################################################
# USER EDITABLE PART
#
# either setenv FOAM_INST_DIR before sourcing this file or set
# foamInstall below to where OpenFOAM is installed
#
@ -45,9 +47,17 @@ set foamInstall = $HOME/$WM_PROJECT
# set foamInstall = ~$WM_PROJECT
# set foamInstall = /usr/local/$WM_PROJECT
# set foamInstall = /opt/$WM_PROJECT
#
# END OF (NORMAL) USER EDITABLE PART
################################################################################
# note the location for later use (eg, in job scripts)
if ( ! $?FOAM_INST_DIR ) setenv FOAM_INST_DIR $foamInstall
# The old dirs to be cleaned from the various environment variables
# - remove anything under top-level directory.
# NB: the WM_PROJECT_INST_DIR might not be identical between versions
set foamOldDirs="$FOAM_INST_DIR $HOME/$WM_PROJECT/$LOGNAME"
# Location of site/user files
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -165,8 +175,8 @@ default:
endsw
# Clean standard environment variables (path, PATH, MANPATH, LD_LIBRARY_PATH)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Clean standard environment variables (path/PATH, LD_LIBRARY_PATH, MANPATH)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set cleanProg=$WM_PROJECT_DIR/bin/foamCleanPath
if (! $?LD_LIBRARY_PATH ) then
@ -176,21 +186,18 @@ if (! $?MANPATH) then
setenv MANPATH ''
endif
# Remove anything under top-level foam directory
set wildCards="$WM_PROJECT_INST_DIR $HOME/$WM_PROJECT/$LOGNAME"
#- Clean path/PATH
set colonPath=`echo "$path" | sed -e 's/ /:/g'`
set PATH=`$cleanProg "$colonPath" "$wildCards"`
set cleanEnv=`$cleanProg "$colonPath" "$foamOldDirs"`
if ( $status == 0 ) then
set path=`echo "$PATH" | sed -e 's/:/ /g'`
set path=`echo "$cleanEnv" | sed -e 's/:/ /g'`
endif
#- Clean LD_LIBRARY_PATH
setenv LD_LIBRARY_PATH `$cleanProg "$LD_LIBRARY_PATH" "$wildCards"`
setenv LD_LIBRARY_PATH `$cleanProg "$LD_LIBRARY_PATH" "$foamOldDirs"`
#- Clean MANPATH
setenv MANPATH `$cleanProg "$MANPATH" "$wildCards"`
setenv MANPATH `$cleanProg "$MANPATH" "$foamOldDirs"`
# Source project setup files
@ -205,15 +212,16 @@ _foamSource $WM_PROJECT_DIR/etc/aliases.csh
# _foamSource $WM_PROJECT_DIR/etc/apps/paraview/cshrc
_foamSource $WM_PROJECT_DIR/etc/apps/paraview3/cshrc
# _foamSource $WM_PROJECT_DIR/etc/apps/ensight/cshrc
# _foamSource $WM_PROJECT_DIR/etc/apps/cint/cshrc
# Again clean environment (path, PATH, MANPATH, LD_LIBRARY_PATH)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#- Clean path/PATH. Only remove duplicates
# Clean environment paths again. Only remove duplicates
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#- Clean path/PATH
set colonPath=`echo "$path" | sed -e 's/ /:/g'`
set PATH=`$cleanProg "$colonPath"`
set cleanEnv=`$cleanProg "$colonPath"`
if ( $status == 0 ) then
set path=`echo "$PATH" | sed -e 's/:/ /g'`
set path=`echo "$cleanEnv" | sed -e 's/:/ /g'`
endif
#- Clean LD_LIBRARY_PATH
@ -229,8 +237,7 @@ endif
# cleanup environment:
# ~~~~~~~~~~~~~~~~~~~~
unset cleanProg
unset wildCards
unset colonPath
unset cleanEnv cleanProg colonPath foamInstall foamOldDirs
unalias _foamSource
# -----------------------------------------------------------------------------