2 #------------------------------------------------------------------------------
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
6 # \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
8 #------------------------------------------------------------------------------
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
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/>.
26 # foamUpdateCaseFileHeader
29 # Updates the header of application files.
30 # By default, writes current version in the header.
31 # Alternatively version can be specified with -v option.
32 # Also removes consecutive blank lines from file.
34 #------------------------------------------------------------------------------
37 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
40 Usage: ${0##*/} [OPTION] <file1> ... <fileN>
43 -version <ver> specifies the version to be written in the header
46 Updates the header of application files and removes consecutive blank lines.
47 By default, writes current OpenFOAM version in the header.
48 An alternative version can be specified with the -version option.
54 #------------------------------------------------------------------------------
64 [ "$#" -ge 2 ] || usage
"'$1' option requires an argument"
69 usage
"unknown option: '$*'"
77 # constant width for version - default to WM_PROJECT_VERSION
78 version
=$
(printf %-36s ${version:-$WM_PROJECT_VERSION})
82 #------------------------------------------------------------------------------
87 /*--------------------------------*- C++ -*----------------------------------*\\
89 | \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
90 | \\\\ / O peration | Version: $version |
91 | \\\\ / A nd | Web: www.OpenFOAM.org |
92 | \\\\/ M anipulation | |
93 \\*---------------------------------------------------------------------------*/
106 # extract attribute '$1' from file '$2'
110 sed -n -e 's/[ ;]*$//' -e "s/^ *$1 *//p" $2
118 tmpFile
=FoamFile.tmp$$
121 if grep FoamFile
$caseFile >/dev
/null
2>&1
123 echo "Updating case file: $caseFile"
124 sed -n '/FoamFile/,/}/p' $caseFile > $tmpFile
126 format
=$
(FoamFileAttribute format
$tmpFile)
127 class
=$
(FoamFileAttribute class
$tmpFile)
128 object
=$
(FoamFileAttribute object
$tmpFile)
129 # extract note? - needs special handling
132 printHeader
$format $class $object "$note" > $tmpFile
134 sed '1,/}/d' $caseFile |
sed '/./,/^$/!d' >> $tmpFile
136 # use cat to avoid removing/replace soft-links
137 [ -s $tmpFile ] && cat $tmpFile >|
$caseFile
138 rm -f $tmpFile 2>/dev
/null
140 echo " Invalid case file: $caseFile" 1>&2
144 #------------------------------------------------------------------ end-of-file