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
=@FOAM_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 /*------------------------------*- FOAMDict -*-------------------------------*\\
58 | ______ _ ____ __ __ |
59 | | ____| _| |_ / __ \\ /\\ | \\/ | |
60 | | |__ _ __ ___ ___ / \\| | | | / \\ | \\ / | |
61 | | __| '__/ _ \\/ _ ( (| |) ) | | |/ /\\ \\ | |\\/| | |
62 | | | | | | __/ __/\\_ _/| |__| / ____ \\| | | | |
63 | |_| |_| \\___|\\___| |_| \\____/_/ \\_\\_| |_| |
65 | FreeFOAM: The Cross-Platform CFD Toolkit |
66 | Version: ${foamVersion} |
67 | Web: http://freefoam.sourceforge.net |
68 \\*---------------------------------------------------------------------------*/
81 # extract attribute '$1' from file '$2'
84 sed -n -e 's/[ ;]*$//' -e "s/^ *$1 *//p" $2
94 echo "Aborting due to invalid option"
98 while [ "$1" != "--" ]
113 [ $# -ge 1 ] || usage
116 # constant width for version
117 foamVersion
=$
(printf %-36s $foamVersion)
126 if grep FoamFile
$caseFile >/dev
/null
2>&1
128 echo "Updating case file: $caseFile"
129 sed -n '/FoamFile/,/}/p' $caseFile > FoamFile.tmp
131 FORMAT
=$
(FoamFileAttribute format FoamFile.tmp
)
132 CLASS
=$
(FoamFileAttribute class FoamFile.tmp
)
133 OBJECT
=$
(FoamFileAttribute object FoamFile.tmp
)
136 printHeader
$FORMAT $CLASS $OBJECT $NOTE > FoamFile.tmp
137 sed '1,/}/d' $caseFile |
sed '/./,/^$/!d' >> FoamFile.tmp
139 # use cat to avoid removing/replace soft-links
140 [ -s FoamFile.tmp
] && cat FoamFile.tmp
>|
$caseFile
141 rm -f FoamFile.tmp
2>/dev
/null
143 echo " Invalid case file: $caseFile" 1>&2
147 #------------------------------------------------------------------------------