mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
sun porting
This commit is contained in:
28
bin/tools/inlineReplace
Executable file
28
bin/tools/inlineReplace
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
# $0 string1 string2 file1 .. filen
|
||||
#
|
||||
if [ $# -lt 3 ]; then
|
||||
echo "Usage: `basename $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)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FROMSTRING=$1
|
||||
shift
|
||||
TOSTRING=$1
|
||||
shift
|
||||
|
||||
for f in $*
|
||||
do
|
||||
if grep "$FROMSTRING" "$f" >/dev/null
|
||||
then
|
||||
cp "$f" "${f}_bak"
|
||||
sed -e "s@$FROMSTRING@$TOSTRING@g" "${f}"_bak > "$f"
|
||||
rm -f "${f}"_bak
|
||||
#else
|
||||
# echo "String $FROMSTRING not present in $f"
|
||||
#fi
|
||||
done
|
||||
15
bin/tools/replaceAllShellSun
Executable file
15
bin/tools/replaceAllShellSun
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/xpg4/bin/sh
|
||||
|
||||
# Replace all shell script headers with
|
||||
if [ $# -ne 1 -o ! -d "$1" ]; then
|
||||
echo "Usage: `basename $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
|
||||
|
||||
Reference in New Issue
Block a user