Scripts in bin: foamUpdateCaseFileHeader check on version number
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
# ========= |
|
# ========= |
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
# \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
@ -32,9 +32,14 @@
|
|||||||
# Also removes consecutive blank lines from file.
|
# Also removes consecutive blank lines from file.
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
usage() {
|
error() {
|
||||||
exec 1>&2
|
exec 1>&2
|
||||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
cat<<USAGE
|
cat<<USAGE
|
||||||
|
|
||||||
Usage: ${0##*/} [OPTION] <file1> ... <fileN>
|
Usage: ${0##*/} [OPTION] <file1> ... <fileN>
|
||||||
@ -48,25 +53,21 @@ options:
|
|||||||
An alternative version can be specified with the -version option.
|
An alternative version can be specified with the -version option.
|
||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
exit 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# parse options
|
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h | -help)
|
-h | -help)
|
||||||
usage
|
usage && exit 0
|
||||||
;;
|
;;
|
||||||
-v | -version)
|
-v | -version)
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || error "'$1' option requires an argument"
|
||||||
version="$2"
|
version="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
-*)
|
-*)
|
||||||
usage "unknown option: '$*'"
|
error "unknown option: '$*'"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
break
|
break
|
||||||
@ -74,12 +75,14 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "$version" | grep -Eq '^([0-9]\.[0-9]|dev)$' || \
|
||||||
|
error "The version number is \"${version}\"." \
|
||||||
|
"The format must be MAJOR.MINOR (e.g. \"4.1\") or \"dev\""
|
||||||
|
|
||||||
# constant width for version - default to WM_PROJECT_VERSION
|
# constant width for version - default to WM_PROJECT_VERSION
|
||||||
version=$(printf %-36s ${version:-$WM_PROJECT_VERSION})
|
version=$(printf %-36s "${version:-$WM_PROJECT_VERSION}")
|
||||||
|
|
||||||
[ $# -ge 1 ] || usage
|
[ $# -ge 1 ] || error
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
printHeader()
|
printHeader()
|
||||||
{
|
{
|
||||||
@ -107,7 +110,7 @@ HEADER
|
|||||||
#
|
#
|
||||||
FoamFileAttribute()
|
FoamFileAttribute()
|
||||||
{
|
{
|
||||||
sed -n -e 's/[ ;]*$//' -e "s/^ *$1 *//p" $2
|
sed -n -e 's/[ ;]*$//' -e "s/^ *$1 *//p" "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -126,10 +129,8 @@ do
|
|||||||
format=$(FoamFileAttribute format $tmpFile)
|
format=$(FoamFileAttribute format $tmpFile)
|
||||||
class=$(FoamFileAttribute class $tmpFile)
|
class=$(FoamFileAttribute class $tmpFile)
|
||||||
object=$(FoamFileAttribute object $tmpFile)
|
object=$(FoamFileAttribute object $tmpFile)
|
||||||
# extract note? - needs special handling
|
|
||||||
unset note
|
|
||||||
|
|
||||||
printHeader $format $class $object "$note" > $tmpFile
|
printHeader "$format" "$class" "$object" > $tmpFile
|
||||||
|
|
||||||
sed '1,/}/d' $caseFile | sed '/./,/^$/!d' >> $tmpFile
|
sed '1,/}/d' $caseFile | sed '/./,/^$/!d' >> $tmpFile
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user