Skip to content
Snippets Groups Projects
Commit e8eb1707 authored by Henry Weller's avatar Henry Weller
Browse files

FreeBSD sed: ensure that a "-e" option immediately follows "-i"

parent a6d2cefa
Branches
Tags
1 merge request!25Merge foundation
#!/bin/sh
# $0 oldString newString file1 .. fileN
#
if [ $# -lt 3 ]
then
echo "Usage: ${0##*/} <oldString> <newString> <file1> [.. fileN]"
echo ""
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
oldString="$1"
newString="$2"
shift 2
for f
do
if grep "$oldString" "$f" >/dev/null
then
cp "$f" "${f}_bak"
sed -e "s@$oldString@$newString@g" "${f}_bak" > "$f"
rm -f "${f}_bak"
#else
# 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) 2011-2013 OpenFOAM Foundation
# \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
# \\/ M anipulation |
#------------------------------------------------------------------------------
# License
......@@ -290,7 +290,7 @@ checkCopyright()
then
echo "Updated copyright for: $f" 1>&2
echo "$f"
sed -i "s/$startYear-$endYear OpenFOAM/$startYear-$year OpenFOAM/g" $f
sed -i -e "s/$startYear-$endYear OpenFOAM/$startYear-$year OpenFOAM/g" $f
fi
else
# Date is of type 2011 OpenFOAM Foundation
......@@ -298,7 +298,7 @@ checkCopyright()
then
echo "$f"
echo "Updated copyright for: $f" 1>&2
sed -i "s/$startYear OpenFOAM/$startYear-$year OpenFOAM/g" $f
sed -i -e "s/$startYear OpenFOAM/$startYear-$year OpenFOAM/g" $f
fi
fi
fi
......
#!/usr/xpg4/bin/sh
# Replace all shell script headers with
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
fi
#- note that below does not work since {} does not get replaced
#find $1 -type f -exec /usr/xpg4/bin/sh -c "grep '^#\!/bin/sh' {} >/dev/null && echo {} && mv {} {}_bak && sed -e 's@^#\!/bin/sh@#\!/usr/xpg4/bin/sh@' {}_bak > {}" ';'
find $1 -exec $WM_PROJECT_DIR/bin/tools/inlineReplace '^#\!/bin/sh' '#\!/usr/xpg4/bin/sh' {} \; -print
# ----------------------------------------------------------------- end-of-file
......@@ -9,7 +9,7 @@ application=`getApplication`
runApplication star3ToFoam prostar/nacaAirfoil
sed -i 's/symmetry\([)]*;\)/empty\1/' constant/polyMesh/boundary
sed -i -e 's/symmetry\([)]*;\)/empty\1/' constant/polyMesh/boundary
runApplication $application
......
......@@ -30,7 +30,7 @@ rm -rf system/wallFilmRegion
cp -r system/wallFilmRegion.org system/wallFilmRegion
find ./0 -maxdepth 1 -type f -exec \
sed -i "s/wallFilm/\"(region0_to.*)\"/g" {} \;
sed -i -e "s/wallFilm/\"(region0_to.*)\"/g" {} \;
paraFoam -touch
paraFoam -touch -region wallFilmRegion
......@@ -2,7 +2,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
# \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
# \\/ M anipulation |
#------------------------------------------------------------------------------
# License
......@@ -68,16 +68,9 @@ $(SFILES): $(MAKE_DIR)/files
# Add a newline to files to ensure the last line is followed by a newline
@echo "" >> $(SFILES)
# Remove commented lines, blank lines, and trailing blanks from files
@sed -i \
-e '/^#/ d' \
-e '/^[ \t]*$$/ d' \
-e 's,[ \t]*$$,,' \
$(SFILES)
@sed -i -e '/^#/ d' -e '/^[ \t]*$$/ d' -e 's,[ \t]*$$,,' $(SFILES)
# Add backslashes
@sed -i \
-e 's,$$, \\,' \
-e '$$s,\\,,' \
$(SFILES)
@sed -i -e 's,$$, \\,' -e '$$s,\\,,' $(SFILES)
$(VARS): $(SFILES)
......
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