2 #---------------------------------*- sh -*-------------------------------------
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
6 # \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
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 #------------------------------------------------------------------------------
35 foamVersion
=$WM_PROJECT_VERSION
40 Usage: ${0##*/} [OPTION] <file1> ... <fileN>
43 -v 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 -v option.
57 /*--------------------------------*- C++ -*----------------------------------*\\
59 | \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
60 | \\\\ / O peration | Version: ${foamVersion} |
61 | \\\\ / A nd | Web: www.OpenFOAM.com |
62 | \\\\/ M anipulation | |
63 \\*---------------------------------------------------------------------------*/
76 # extract attribute '$1' from file '$2'
79 sed -n -e 's/[ ;]*$//' -e "s/^ *$1 *//p" $2
89 echo "Aborting due to invalid option"
93 while [ "$1" != "--" ]
108 [ $# -ge 1 ] || usage
111 # constant width for version
112 foamVersion
=$
(printf %-36s $foamVersion)
121 if grep FoamFile
$caseFile >/dev
/null
2>&1
123 echo "Updating case file: $caseFile"
124 sed -n '/FoamFile/,/}/p' $caseFile > FoamFile.tmp
126 FORMAT
=$
(FoamFileAttribute format FoamFile.tmp
)
127 CLASS
=$
(FoamFileAttribute class FoamFile.tmp
)
128 OBJECT
=$
(FoamFileAttribute object FoamFile.tmp
)
131 printHeader
$FORMAT $CLASS $OBJECT $NOTE > FoamFile.tmp
132 sed '1,/}/d' $caseFile |
sed '/./,/^$/!d' >> FoamFile.tmp
134 # use cat to avoid removing/replace soft-links
135 [ -s FoamFile.tmp
] && cat FoamFile.tmp
>|
$caseFile
136 rm -f FoamFile.tmp
2>/dev
/null
138 echo " Invalid case file: $caseFile" 1>&2
142 #------------------------------------------------------------------------------