ENH: Added utility to check completeness of installation
[freefoam.git] / data / utilities / replaceAllShellSun
bloba816598fa0a8a8c663c8ebdd5ba380877437dcbf
1 #!/usr/xpg4/bin/sh
3 # Replace all shell script headers with
4 if [ $# -ne 1 -o ! -d "$1" ]; then
5 echo "Usage: `basename $0` <dir>"
6 echo ""
7 echo "Replaces all occurrences of #!/bin/sh with #!/usr/xpg4/bin/sh inside a directory tree."
8 exit 1
9 fi
11 inlineReplace() {
12 if [ $# -lt 3 ]; then
13 echo "Usage: inlineReplace <string1> <string2> <file1> .. <filen>"
14 echo ""
15 echo "Replaces all occurrences of string1 by string2 in files."
16 echo "(replacement of sed -i on those systems that don't support it)"
17 exit 1
19 FROMSTRING=$1
20 shift
21 TOSTRING=$1
22 shift
24 for f in $*
26 if grep "$FROMSTRING" "$f" >/dev/null
27 then
28 cp "$f" "${f}_bak"
29 sed -e "s@$FROMSTRING@$TOSTRING@g" "${f}"_bak > "$f"
30 rm -f "${f}"_bak
32 done
35 find $1 -type f -print | \
36 while read f; do
37 inlineReplace '^#\!/bin/sh' '#\!/usr/xpg4/bin/sh' "$f"
38 done