ENH: patchCloud: return pTraits<Type>::max for unfound points
[OpenFOAM-1.7.x.git] / bin / rmdepold
blob8b6290add0d3a9d42b310052c5415637bbdde34e
1 #!/bin/sh
2 #---------------------------------*- sh -*-------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
7 # \\/ M anipulation |
8 #------------------------------------------------------------------------------
9 # License
10 # This file is part of OpenFOAM.
12 # OpenFOAM is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your option) any later version.
17 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
18 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 # for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 # Script
26 # rmdepold
28 # Description
29 # Usage: rmdepold [dir1 .. dirN]
31 # Remove *.dep files that are without a corresponding .C or .L file.
32 # This often occurs when a directory has been moved.
33 # - print questionable directory and the *.dep file
34 # - optionally remove empty directories
35 #------------------------------------------------------------------------------
36 usage() {
37 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
38 cat<<USAGE 1>&2
39 Usage: ${0##*/} [OPTION] [dir1 .. dirN]
40 options:
41 -rmdir find and remove empty directories (recursively)
43 Remove *.dep files that are without a corresponding .C or .L file.
44 This often occurs when a directory has been moved.
45 - print questionable directory and file
46 - optionally remove empty directories
48 USAGE
49 exit 1
52 unset optRmdir
54 # parse options
55 while [ "$#" -gt 0 ]
57 case "$1" in
58 -h | -help)
59 usage
61 -rmdir)
62 optRmdir=true
63 shift
65 -*)
66 usage "unknown option: '$*'"
69 break
71 esac
72 done
74 # default is the current directory
75 [ "$#" -gt 0 ] || set -- .
77 for checkDir
79 if [ -d $checkDir ]
80 then
81 echo "searching: $checkDir"
82 else
83 echo "skipping non-dir: $checkDir"
84 continue
87 find $checkDir -name '*.dep' -print | while read depFile
89 # check C++ and Flex files
90 if [ ! -r "${depFile%dep}C" -a ! -r "${depFile%dep}L" ];
91 then
92 echo "rm $depFile"
93 rm -f $depFile 2>/dev/null
95 done
97 # remove empty dirs
98 if [ "$optRmdir" ]
99 then
100 # get subdirs ourselves so we can avoid particular directories
101 for dir in $(find $checkDir -mindepth 1 -maxdepth 1 -type d \( -name .git -prune -o -print \) )
103 echo "check dir: $dir"
104 find $dir -depth -type d -empty -exec rmdir {} \; -print
105 done
107 done
108 # -----------------------------------------------------------------------------