Reviewed all *inter*Foam tutorials
[foam-extend-3.0.git] / bin / foamVersion
blob0abc63eeb3441a24bb1741dbf94390be7ee28963
1 #!/bin/bash
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright held by original author
7 # \\/ M anipulation |
8 #------------------------------------------------------------------------------
9 # License
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 the
14 # Free Software Foundation; either version 2 of the License, or (at your
15 # 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
20 # for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with OpenFOAM; if not, write to the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 # Script
27 # foamVersion
29 # Description
30 # Report on OpenFOAM version, and source code revision number.
31 # This implementation is using the Subversion revision control system
32 # for retrieving the revision number.
34 # Author:
35 # Martin Beaudoin, Hydro-Quebec, (2009)
37 #------------------------------------------------------------------------------
38 Script=${0##*/}
40 usage() {
41 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
42 cat<<USAGE
44 Usage: $Script [-revision] [-help]
46 Report on the version of OpenFOAM, and if available, the source code revision number.
48 If the source code revision number is not directly available, then the string
49 "exported" will be reported for the revision number.
51 Options:
52 -revision : Report only the revision number
53 -help : this help
55 USAGE
56 exit 1
60 # Initialize the SVN client command
61 SVN_CMD='svn'
63 # initialize the Revision number to "exported" by default.
64 # This is the expected information reported by svnversion when the source code is not from a
65 # svn working copy
66 FOAM_DEV_SVN_REVISION_NUMBER="exported"
68 if [ -e $WM_PROJECT_DIR/.svn ]
69 then
70 # Check if a svn client in available
71 status=`$SVN_CMD --version --quiet >& /dev/null`
73 if [ "$?" -eq 0 ]
74 then
75 # We are not using svnversion here because it is recursive, and this can take a while.
77 # We are forcing LC_ALL=C in order to get rid of any locale variations in the ouput of
78 # the command $SVN_CMD
80 # We are grabbing the revision number associated to "Last Changed Rev:" for the svn repository
81 # branch associated with $WM_PROJECT_DIR. That way, we will not pickup changes in revision number
82 # coming from other parts of the Subversion repository.
84 FOAM_DEV_SVN_REVISION_NUMBER=`LC_ALL=C $SVN_CMD info $WM_PROJECT_DIR | grep "Last Changed Rev:" | awk '{print $4}'`;
88 case "$1" in
89 -revision)
90 shift
91 # Only output the svn version number. Handy when called from Makefiles or scripts
92 echo $FOAM_DEV_SVN_REVISION_NUMBER
94 -help)
95 shift
96 usage
100 if [ $FOAM_DEV_SVN_REVISION_NUMBER ]
101 then
102 echo "OpenFOAM version $WM_PROJECT_VERSION, revision $FOAM_DEV_SVN_REVISION_NUMBER"
103 else
104 echo "OpenFOAM version $WM_PROJECT_VERSION"
107 esac
112 #------------------------------------------------------------------------------