Commit f1d03a38 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: cleanup shell scripts, BUG: unclosed 'if' in inlineReplace

parent 56a5650f
......@@ -30,7 +30,7 @@
# Locate user/group/shipped file with semantics similar to the
# ~OpenFOAM/fileName expansion.
#
# The -mode option can be used to allow chaining from
# The -mode option can be used to allow chaining from
# personal settings to site-wide settings.
#
# For example, within the user ~/.OpenFOAM/<VER>/prefs.sh:
......@@ -119,27 +119,27 @@ nArgs=$#
fileName="$1"
# Define the various places to be searched:
files=""
unset dirList
case "$mode" in
*u*) # user
files="$files $HOME/.${WM_PROJECT:-OpenFOAM}/$WM_PROJECT_VERSION"
files="$files $HOME/.${WM_PROJECT:-OpenFOAM}"
dirList="$dirList $HOME/.${WM_PROJECT:-OpenFOAM}/$WM_PROJECT_VERSION"
dirList="$dirList $HOME/.${WM_PROJECT:-OpenFOAM}"
;;
esac
case "$mode" in
*g*) # group
files="$files $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION"
files="$files $WM_PROJECT_INST_DIR/site"
dirList="$dirList $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION"
dirList="$dirList $WM_PROJECT_INST_DIR/site"
;;
esac
case "$mode" in
*o*) # other
files="$files $WM_PROJECT_DIR/etc"
dirList="$dirList $WM_PROJECT_DIR/etc"
;;
esac
set -- $files
set -- $dirList
#
......
......@@ -46,7 +46,7 @@ if [ $# = 0 -a -f "./Allrun" ]
then
# Specialised script.
./Allrun
elif [ -d "./system" ]
elif [ -d system ]
then
# Normal case.
parentDir=`dirname $PWD`
......@@ -55,19 +55,19 @@ then
runApplication $application
else
# Loop over sub-directories and compile any applications
for case in *
for caseName in *
do
if [ -d $case -a -d "$case/Make" ]
if [ -d $caseName -a -d "$caseName/Make" ]
then
(compileApplication $case)
( compileApplication $caseName )
fi
done
# Recurse to subdirectories
for case in *
for caseName in *
do
if [ -d $case ]
if [ -d $caseName ]
then
(cd $case && $thisScript)
( cd $caseName && $thisScript )
fi
done
fi
......
......@@ -45,12 +45,12 @@ for cmd in etags ectags
do
type $cmd >/dev/null 2>&1 || {
echo "${0##*/} cannot build tag files: '$cmd' command not found"
exit
exit 1
}
done
cd $WM_PROJECT_DIR || exit
cd $WM_PROJECT_DIR || exit 1
mkdir .tags 2>/dev/null
......
......@@ -49,7 +49,7 @@ do
echo "removing all *~ files: $i"
find $i \( -name '*~' -o -name '.*~' \) -print | xargs -t rm 2>/dev/null
else
echo "no directory: $i" 1>&2
echo "no directory: $i" 1>&2
fi
done
......
#!/bin/sh
# $0 string1 string2 file1 .. filen
# $0 oldString newString file1 .. fileN
#
if [ $# -lt 3 ]
then
echo "Usage: ${0##*/} [-f] <string1> <string2> <file1> .. <filen>"
echo "Usage: ${0##*/} <oldString> <newString> <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)"
echo "Replaces all occurrences of oldString by newString in files."
echo "(replacement for sed -i on systems that don't support it)"
exit 1
fi
FROMSTRING=$1
shift
TOSTRING=$1
shift
oldString="$1"
newString="$2"
shift 2
for f in $*
for f
do
if grep "$FROMSTRING" "$f" >/dev/null
if grep "$oldString" "$f" >/dev/null
then
cp "$f" "${f}_bak"
sed -e "s@$FROMSTRING@$TOSTRING@g" "${f}"_bak > "$f"
rm -f "${f}"_bak
sed -e "s@$oldString@$newString@g" "${f}_bak" > "$f"
rm -f "${f}_bak"
#else
# echo "String $FROMSTRING not present in $f"
#fi
# echo "String $oldString not present in $f"
fi
done
# ----------------------------------------------------------------- end-of-file
......@@ -3,7 +3,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
......@@ -58,13 +58,14 @@ USAGE
#------------------------------------------------------------------------------
# simple option parsing
unset forceUpdate
# default 'find' option
unset findOpt
# default ln option
# default 'ln' option
lnOpt="-s"
unset forceUpdate
# simple parse options
while [ "$#" -gt 0 ]
do
......@@ -74,7 +75,7 @@ do
;;
-f)
shift
forceUpdate=1
forceUpdate=true
lnOpt="-sf"
;;
-*)
......@@ -110,28 +111,25 @@ done
incDir=$baseDir/lnInclude
if [ ! -d $baseDir ]
then
[ -d $baseDir ] || {
echo "$Script error: base directory $baseDir does not exist" 1>&2
exit 2
fi
}
if [ -d $incDir ]
then
if [ ! "$forceUpdate" ]
then
# echo "$Script error: include directory $incDir already exists" 1>&2
exit 0
fi
[ "$forceUpdate" = true ] || {
# echo "$Script error: include directory $incDir already exists" 1>&2
exit 0
}
else
mkdir $incDir
fi
if [ ! -d $incDir ]
then
[ -d $incDir ] || {
echo "$Script error: failed to create include directory $incDir" 1>&2
exit 0
fi
}
cd $incDir || exit 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment