Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | #!/bin/sh |
2 | # | |
3 | # move-if-changed <file1> <file2> | |
4 | # | |
5 | # if (file2 != file1) then copy file2 to file1. | |
6 | # | |
7 | src=$1 | |
8 | dest=$2 | |
9 | tmp1=$src.tmp | |
10 | tmp2=$dest.tmp | |
11 | ||
12 | RM="/usr/bin/rm -f" | |
13 | GREP="/usr/bin/grep" | |
14 | SCCS="/usr/ccs/bin/sccs" | |
15 | CP="/usr/bin/cp -p" | |
16 | TOUCH="/usr/bin/touch" | |
17 | CMP="/usr/bin/cmp -s" | |
18 | CHMOD="/usr/bin/chmod" | |
19 | ||
20 | $RM $tmp1 $tmp2 | |
21 | $GREP -v '#' $src > $tmp1 | |
22 | $GREP -v '#' $dest > $tmp2 | |
23 | $TOUCH $tmp1 $tmp2 | |
24 | if $CMP $tmp1 $tmp2; then | |
25 | /bin/true | |
26 | else | |
27 | dir=`dirname $src`; | |
28 | fname=`basename $src`; | |
29 | here=`pwd`; | |
30 | cd $dir | |
31 | $CHMOD -w $fname | |
32 | $RM SCCS/p.$fname | |
33 | $SCCS edit $fname > /dev/null | |
34 | cd $here | |
35 | $CP -f $dest $src | |
36 | fi | |
37 | $RM $tmp1 $tmp2 $dest | |
38 | exit 0 |