From ef86cd63d14c1cba40c9bdace5357b0216942ee1 Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Sun, 6 Mar 2016 19:13:45 +0000
Subject: [PATCH] Update "wrmdep -update" to remove dead symbolic links Patch
 provided by Bruno Santos Resolved bug-report
 http://www.openfoam.org/mantisbt/view.php?id=2016

---
 wmake/wrmdep | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/wmake/wrmdep b/wmake/wrmdep
index b390205d8cc..d5bf4f26587 100755
--- a/wmake/wrmdep
+++ b/wmake/wrmdep
@@ -3,7 +3,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2015 OpenFOAM Foundation
+#   \\  /    A nd           | Copyright (C) 2015-2016 OpenFOAM Foundation
 #    \\/     M anipulation  |
 #-------------------------------------------------------------------------------
 # License
@@ -196,11 +196,11 @@ updateMode)
         || usage "Not in the project top-level directory"
 
     echo "Purging all dep files that relate to files that no longer exist..."
-    fileNameList=$(find -L src applications -name '*.[CHL]' -type l \
-                        -exec basename {} \;)
+    fileNameList=$(find -L src applications -name '*.[CHL]' -type l)
 
-    for fileName in $fileNameList
+    for filePathAndName in $fileNameList
     do
+        fileName=$(basename $filePathAndName)
         echo "Purging from 'src': $fileName"
         cd src
         $Script -a $fileName
@@ -210,6 +210,9 @@ updateMode)
         $Script -a $fileName
 
         cd ..
+
+        # Just in case, remove the symbolic link as the last step
+        unlink $filePathAndName
     done
 
     ;;
-- 
GitLab