STYLE: more consistent shell style in tutorial run/clean scripts

This commit is contained in:
Mark Olesen
2010-03-10 10:55:42 +01:00
parent 2068c67a33
commit 6b6dd51a27
112 changed files with 721 additions and 260 deletions

View File

@ -29,13 +29,14 @@
#
#------------------------------------------------------------------------------
#cleanTimeDirectories ()
#cleanTimeDirectories()
#{
# echo "Cleaning $case case of $application application"
# TIME_DIRS=`foamInfoExec . $1 -times | sed '1,/constant/d'`
# for T in $TIME_DIRS
# do
# if [ $T != "0" ] ; then
# if [ $T != "0" ]
# then
# echo "Deleting directory $T"
# rm -rf ${T} > /dev/null 2>&1
# fi
@ -43,12 +44,13 @@
# rm -rf {log,log.*,log-*,logSummary.*,.fxLock,*.xml,ParaView*,paraFoam*,*.OpenFOAM} > /dev/null 2>&1
#}
cleanTimeDirectories ()
cleanTimeDirectories()
{
echo "Cleaning $PWD case"
nZeros=0
zeros=""
while [ $nZeros -lt 8 ] ; do
while [ $nZeros -lt 8 ]
do
timeDir="0.${zeros}[1-9]*"
rm -rf ${timeDir} > /dev/null 2>&1
rm -rf ./-${timeDir} > /dev/null 2>&1
@ -58,7 +60,7 @@ cleanTimeDirectories ()
rm -rf ./{[1-9]*,-[1-9]*,log,log.*,log-*,logSummary.*,.fxLock,*.xml,ParaView*,paraFoam*,*.OpenFOAM} > /dev/null 2>&1
}
cleanCase ()
cleanCase()
{
cleanTimeDirectories
rm -rf processor* > /dev/null 2>&1
@ -82,23 +84,23 @@ cleanCase ()
done
}
removeCase ()
removeCase()
{
echo "Removing $case case"
rm -rf $1
}
cleanSamples ()
cleanSamples()
{
rm -rf {sets,samples,sampleSurfaces} > /dev/null 2>&1
}
cleanUcomponents ()
cleanUcomponents()
{
rm -rf 0/{Ux,Uy,Uz} > /dev/null 2>&1
}
cleanApplication ()
cleanApplication()
{
echo "Cleaning $PWD application"
wclean

View File

@ -29,17 +29,19 @@
#
#------------------------------------------------------------------------------
getApplication ()
getApplication()
{
grep application system/controlDict | sed "s/application *\([a-zA-Z]*\);/\1/"
}
runApplication ()
runApplication()
{
APP_RUN=$1; shift
APP_RUN=$1
shift
APP_NAME=${APP_RUN##*/}
if [ -f log.$APP_NAME ] ; then
if [ -f log.$APP_NAME ]
then
echo "$APP_NAME already run on $PWD: remove log file to run"
else
echo "Running $APP_RUN on $PWD"
@ -47,11 +49,13 @@ runApplication ()
fi
}
runParallel ()
runParallel()
{
APP_RUN=$1; shift
APP_RUN=$1
shift
if [ -f $log.$APP_RUN ] ; then
if [ -f $log.$APP_RUN ]
then
echo "$APP_RUN already run on $PWD: remove log file to run"
else
echo "Running $APP_RUN in parallel on $PWD using $1 processes"
@ -59,15 +63,16 @@ runParallel ()
fi
}
compileApplication ()
compileApplication()
{
echo "Compiling $1 application"
wmake $1
}
cloneCase ()
cloneCase()
{
if [ -d $2 ] ; then
if [ -d $2 ]
then
echo "Case already cloned: remove case directory $2 to clone"
else
echo "Cloning $2 case from $1"

View File

@ -2,8 +2,9 @@
# $0 string1 string2 file1 .. filen
#
if [ $# -lt 3 ]; then
echo "Usage: `basename $0` [-f] <string1> <string2> <file1> .. <filen>"
if [ $# -lt 3 ]
then
echo "Usage: ${0##*/} [-f] <string1> <string2> <file1> .. <filen>"
echo ""
echo "Replaces all occurrences of string1 by string2 in files."
echo "(replacement of sed -i on those systems that don't support it)"
@ -26,3 +27,5 @@ do
# echo "String $FROMSTRING not present in $f"
#fi
done
# ----------------------------------------------------------------- end-of-file

View File

@ -1,8 +1,9 @@
#!/usr/xpg4/bin/sh
# Replace all shell script headers with
if [ $# -ne 1 -o ! -d "$1" ]; then
echo "Usage: `basename $0` <dir>"
if [ $# -ne 1 -o ! -d "$1" ]
then
echo "Usage: ${0##*/} <dir>"
echo ""
echo "Replaces all occurrences of #!/bin/sh with #!/usr/xpg4/bin/sh inside a directory tree."
exit 1
@ -13,3 +14,4 @@ fi
find $1 -exec $WM_PROJECT_DIR/bin/tools/inlineReplace '^#\!/bin/sh' '#\!/usr/xpg4/bin/sh' {} \; -print
# ----------------------------------------------------------------- end-of-file