Skip to content

Commit 163dc74

Browse files
author
Chris Greenshields
committed
foamSearch: make it work within a read-only directory
Patch contributed by Bruno Santos: https://bugs.openfoam.org/view.php?id=2928
1 parent d0dfb1a commit 163dc74

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

bin/foamSearch

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# ========= |
44
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
55
# \\ / O peration |
6-
# \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation
6+
# \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
77
# \\/ M anipulation |
88
#-------------------------------------------------------------------------------
99
# License
@@ -48,6 +48,7 @@ Searches the <directory> for files named <filename> and extracts entries with
4848
Examples:
4949
* Default ddtSchemes entries in the fvSchemes files in all tutorials:
5050
foamSearch $FOAM_TUTORIALS fvSchemes ddtSchemes.default
51+
5152
* Relaxations factors for U in fvSolutions files in all tutorials:
5253
foamSearch -c $FOAM_TUTORIALS fvSolution relaxationFactors.equations.U
5354
USAGE
@@ -75,19 +76,14 @@ esac
7576
[ "$#" -eq 3 ] || error "Wrong number of arguments: expected 3, found $#"
7677
[ -d "$1" ] || error "$1 is not a directory"
7778

78-
tmp=$(mktemp tmp.XXXXXX)
7979
files=$(find "$1" -name "$2")
8080
[ -n "$files" ] || error "No file $2 found in $1"
8181

8282
for f in $files
8383
do
84-
foamDictionary -entry "$3" "$f" 2>/dev/null >> "$tmp"
85-
done
86-
87-
[ -s "$tmp" ] && \
88-
sort "$tmp" | uniq $count | sed '/^[\t 1-9]*$/d' || \
84+
foamDictionary -entry "$3" "$f" 2>/dev/null
85+
done | \
86+
sort | uniq $count | sed '/^[\t 1-9]*$/d' || \
8987
echo "No keyword $3 found in $2 files"
9088

91-
rm "$tmp" 2>/dev/null
92-
9389
#------------------------------------------------------------------------------

0 commit comments

Comments
 (0)