From f7e4137ee5539e01c6aee192985230fb76e2b115 Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Thu, 5 May 2016 15:37:00 +0100
Subject: [PATCH] etc/bashrc, etc/cshrc: Filter $WM_PROJECT_DIR from paths
 rather than $FOAM_INST_DIR Additionally filter $ParaView_DIR from paths in
 config.sh/paraview and config.csh/paraview

Resolves bug-report http://bugs.openfoam.org/view.php?id=2031
---
 etc/bashrc              | 12 +++---------
 etc/config.csh/paraview |  2 +-
 etc/config.sh/aliases   |  4 ++--
 etc/config.sh/ensight   |  6 +++---
 etc/config.sh/functions |  4 ++--
 etc/config.sh/paraview  | 19 ++++++++++---------
 etc/config.sh/unset     | 12 ++++++------
 etc/cshrc               | 13 +++----------
 8 files changed, 30 insertions(+), 42 deletions(-)

diff --git a/etc/bashrc b/etc/bashrc
index aa26e57dbe..0fa2c23174 100644
--- a/etc/bashrc
+++ b/etc/bashrc
@@ -104,15 +104,9 @@ export FOAM_SIGFPE=
 
 ################################################################################
 
-# 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
-foamOldDirs="$FOAM_INST_DIR $WM_PROJECT_SITE $HOME/$WM_PROJECT/$USER"
-if [ "$WM_PROJECT_INST_DIR" != "$FOAM_INST_DIR" ]
-then
-    foamOldDirs="$WM_PROJECT_INST_DIR $foamOldDirs"
-fi
-
+# The old dirs to be cleaned from the environment variables
+foamOldDirs="$WM_PROJECT_DIR $WM_THIRD_PARTY_DIR \
+    $WM_PROJECT_SITE $HOME/$WM_PROJECT/$USER"
 
 # Location of installation
 # ~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/etc/config.csh/paraview b/etc/config.csh/paraview
index 9e5f7eb0f7..239a51c156 100644
--- a/etc/config.csh/paraview
+++ b/etc/config.csh/paraview
@@ -34,7 +34,7 @@
 #------------------------------------------------------------------------------
 
 # clean the PATH
-set cleaned=`$WM_PROJECT_DIR/bin/foamCleanPath "$PATH" "$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/cmake- $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview-"`
+set cleaned=`$WM_PROJECT_DIR/bin/foamCleanPath "$PATH" "$ParaView_DIR $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/cmake- $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview-"`
 if ( $status == 0 ) setenv PATH $cleaned
 
 # determine the cmake to be used
diff --git a/etc/config.sh/aliases b/etc/config.sh/aliases
index 44de3c70b5..6909d9f70d 100644
--- a/etc/config.sh/aliases
+++ b/etc/config.sh/aliases
@@ -38,10 +38,10 @@ alias wm32='wmSET WM_ARCH_OPTION=32'
 alias wmSP='wmSET WM_PRECISION_OPTION=SP'
 alias wmDP='wmSET WM_PRECISION_OPTION=DP'
 
-# refresh the environment
+# Refresh the environment
 alias wmREFRESH='wmSET $FOAM_SETTINGS'
 
-# clear env
+# Clear env
 alias wmUNSET='. $WM_PROJECT_DIR/etc/config.sh/unset'
 
 # Toggle wmakeScheduler on/off
diff --git a/etc/config.sh/ensight b/etc/config.sh/ensight
index aea759741a..616adfdc79 100644
--- a/etc/config.sh/ensight
+++ b/etc/config.sh/ensight
@@ -30,7 +30,7 @@
 #
 #------------------------------------------------------------------------------
 
-# fallback value
+# Fallback value
 if [ ! -d "$CEI_HOME" ]
 then
     export CEI_HOME=/usr/local/ensight/CEI
@@ -39,13 +39,13 @@ fi
 if [ -r $CEI_HOME ]
 then
 
-    # special treatment for 32bit OpenFOAM and 64bit Ensight
+    # Special treatment for 32bit OpenFOAM and 64bit Ensight
     if [ "$WM_ARCH" = linux -a `uname -m` = x86_64 ]
     then
         export CEI_ARCH=linux_2.6_32
     fi
 
-    # add to path if required
+    # Add to path if required
     if [ "$CEI_HOME/bin/ensight" != "`which ensight 2>/dev/null`" ]
     then
         export PATH=$CEI_HOME/bin:$PATH
diff --git a/etc/config.sh/functions b/etc/config.sh/functions
index dcec6549d4..6379b34e6c 100644
--- a/etc/config.sh/functions
+++ b/etc/config.sh/functions
@@ -54,7 +54,7 @@ then
         do
             case "$1" in
             -*)
-                # stray option (not meant for us here) -> get out
+                # Stray option (not meant for us here) -> get out
                 break
                 ;;
             *=)
@@ -68,7 +68,7 @@ then
                 eval "export $1"
                 ;;
             *)
-                # filename: source it
+                # Filename: source it
                 if [ -f "$1" ]
                 then
                     _foamSource "$1"
diff --git a/etc/config.sh/paraview b/etc/config.sh/paraview
index b6216f0579..6153b59798 100644
--- a/etc/config.sh/paraview
+++ b/etc/config.sh/paraview
@@ -33,14 +33,15 @@
 #     are required for building plugins
 #------------------------------------------------------------------------------
 
-# clean the PATH
+# Clean the PATH
 cleaned=$($WM_PROJECT_DIR/bin/foamCleanPath "$PATH" \
-        "$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/cmake- \
-        $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview-" \
+        "$ParaView_DIR \
+         $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/cmake- \
+         $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview-" \
         ) \
         && PATH="$cleaned"
 
-# determine the cmake to be used
+# Determine the cmake to be used
 unset CMAKE_HOME
 for cmake in cmake-3.2.1 cmake-2.8.12.1 cmake-2.8.8 cmake-2.8.4 cmake-2.8.3 \
              cmake-2.8.1
@@ -85,15 +86,15 @@ _foamParaviewEval()
 _foamParaviewEval $@
 
 
-# set MAJOR version to correspond to VERSION
+# Set MAJOR version to correspond to VERSION
 # ParaView_MAJOR is "<digits>.<digits>" from ParaView_VERSION
 case "$ParaView_VERSION" in
 "$ParaView_MAJOR".* )
-    # version and major appear to correspond
+    # Version and major appear to correspond
     ;;
 
 [0-9]*)
-    # extract major from the version
+    # Extract major from the version
     ParaView_MAJOR=$(echo $ParaView_VERSION | \
                    sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/')
     ;;
@@ -105,7 +106,7 @@ paraviewArchName=ParaView-$ParaView_VERSION
 
 export ParaView_DIR=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$paraviewArchName
 
-# set paths if binaries or source are present
+# Set paths if binaries or source are present
 if [ -r $ParaView_DIR -o -r $paraviewInstDir ]
 then
     export ParaView_INCLUDE_DIR=$ParaView_DIR/include/paraview-$ParaView_MAJOR
@@ -129,7 +130,7 @@ then
         echo "    PV_PLUGIN_PATH       : $PV_PLUGIN_PATH"
     fi
 
-    # add in python libraries if required
+    # Add in python libraries if required
     paraviewPython=$ParaView_DIR/Utilities/VTKPythonWrapping
     if [ -r $paraviewPython ]
     then
diff --git a/etc/config.sh/unset b/etc/config.sh/unset
index af44571f03..7b240eeb81 100644
--- a/etc/config.sh/unset
+++ b/etc/config.sh/unset
@@ -44,7 +44,7 @@ then
 fi
 
 #------------------------------------------------------------------------------
-# unset WM_* environment variables
+# Unset WM_* environment variables
 
 unset WM_ARCH
 unset WM_ARCH_OPTION
@@ -75,7 +75,7 @@ unset WM_THIRD_PARTY_DIR
 
 
 #------------------------------------------------------------------------------
-# unset FOAM_* environment variables
+# Unset FOAM_* environment variables
 
 unset FOAM_APPBIN
 unset FOAM_APP
@@ -100,14 +100,14 @@ unset FOAM_UTILITIES
 
 
 #------------------------------------------------------------------------------
-# unset MPI-related environment variables
+# Unset MPI-related environment variables
 
 unset MPI_ARCH_PATH
 unset MPI_BUFFER_SIZE
 unset OPAL_PREFIX
 
 #------------------------------------------------------------------------------
-# unset Ensight/ParaView-related environment variables
+# Unset Ensight/ParaView-related environment variables
 
 unset ENSIGHT9_READER
 unset CMAKE_HOME
@@ -117,7 +117,7 @@ unset PV_PLUGIN_PATH
 
 
 #------------------------------------------------------------------------------
-# cleanup environment
+# Cleanup environment
 # PATH, LD_LIBRARY_PATH, MANPATH
 
 if [ -n "$foamClean" ]
@@ -137,7 +137,7 @@ unset cleaned foamClean foamOldDirs
 
 
 #------------------------------------------------------------------------------
-# cleanup aliases
+# Cleanup aliases
 
 unalias wmSET
 unalias wm64
diff --git a/etc/cshrc b/etc/cshrc
index 249c50afb4..c9a205332e 100644
--- a/etc/cshrc
+++ b/etc/cshrc
@@ -104,16 +104,9 @@ setenv FOAM_SIGFPE
 
 ################################################################################
 
-# 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"
-if ( $?WM_PROJECT_INST_DIR ) then
-    if ( "$WM_PROJECT_INST_DIR" != "$FOAM_INST_DIR" ) then
-        set foamOldDirs="$WM_PROJECT_INST_DIR $foamOldDirs"
-    endif
-endif
-
+# The old dirs to be cleaned from the environment variables
+set foamOldDirs="$WM_PROJECT_DIR $WM_THIRD_PARTY_DIR \
+    $WM_PROJECT_SITE $HOME/$WM_PROJECT/$LOGNAME"
 
 # Location of installation
 # ~~~~~~~~~~~~~~~~~~~~~~~~
-- 
GitLab