From e4b8fedeb1e936422964a5f9d9bc6f8b57bc702d Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Wed, 28 Nov 2018 19:19:10 +0100
Subject: [PATCH] ENH: do not foamCleanPath on system directories (issue #1102)

- skip /, /bin, /usr/bin ... as potential filters.
---
 bin/foamCleanPath | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/bin/foamCleanPath b/bin/foamCleanPath
index 02f7a293a6d..a06d24934a2 100755
--- a/bin/foamCleanPath
+++ b/bin/foamCleanPath
@@ -27,6 +27,7 @@
 #     - false matches possible when the filter contains '.' (sed regex) etc.
 #     - a single composite filter can be passed in. This composite filter
 #       is assumed to be delimited by whitespace, colons or semi-colons.
+#     - will not filter out standard system paths (/usr/bin etc)
 #
 # Examples for cleaning the path:
 #
@@ -194,11 +195,22 @@ printDebug "input>$dirList<"
 # Apply filters via sed. Path and filter cannot contain '?'.
 for filter
 do
-    if [ -n "$filter" ]
-    then
-        printDebug "remove>$filter<"
-        dirList=$(echo "$dirList:" | sed -e "s?${filter}[^:]*:??g")
-    fi
+    case "$filter" in
+    ( / | /bin | /sbin | /lib | /lib64 | /opt \
+        | /usr | /usr/bin | /usr/sbin | /usr/lib | /usr/lib64 \
+        | /usr/local | /usr/local/bin | /usr/local/lib | /usr/local/lib64 )
+        # Do not filter out system directories
+        printDebug "skip>$filter<"
+        ;;
+
+    (*)
+        if [ -n "$filter" ]
+        then
+            printDebug "remove>$filter<"
+            dirList=$(echo "$dirList:" | sed -e "s?${filter}[^:]*:??g")
+        fi
+        ;;
+    esac
 done
 printDebug "intermediate>$dirList<"
 
-- 
GitLab