From b6cb62a53f59f876f8f584919f9cbbfe43f95c9b Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Mon, 10 Dec 2018 10:34:11 +0100
Subject: [PATCH] ENH: handle odd c-shell sourcing patterns

- the result of lsof, which is used in the etc/cshrc to locate the
  installation, may contain trailing information about host and mount
  point.

  There is also a moderate concern with people sourcing the
  file indirectly with their own version in the same directory.
  For example, a 'etc/cshrc-site' that actually sources 'etc/cshrc'.
  This leads to multiple matches in the lsof output, so we only take
  the first one, stop there and hope they didn't do something even
  trickier.
---
 etc/cshrc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/etc/cshrc b/etc/cshrc
index 971041cfa83..8da66078bf3 100644
--- a/etc/cshrc
+++ b/etc/cshrc
@@ -54,7 +54,7 @@ setenv WM_PROJECT_VERSION plus
 # If the directory naming does not match WM_PROJECT, need to change here
 set projectName="$WM_PROJECT"
 set projectDir=`lsof +p $$ |& \
-    sed -n -e 's@^[^/]*@@; s@\(/'"$projectName"'[^/]*\)/etc/cshrc[^/]*@\1@p'`
+    sed -ne 's@^[^/]*@@;\@/'"$projectName"'[^/]*/etc/cshrc@{s@/etc/cshrc.*@@p; q}'`
 
 # set projectDir="$HOME/OpenFOAM/OpenFOAM-$WM_PROJECT_VERSION"
 # set projectDir="/opt/OpenFOAM/OpenFOAM-$WM_PROJECT_VERSION"
-- 
GitLab