1 2 3PATH=/bin:/usr/bin 4DIFF=/usr/bin/diff 5DIFF3=/usr/bin/diff3 6p=w 7case $1 in 8-p) 9 p='1,$p' 10 shift 11esac 12 13case $# in 140|1|2) 15 echo >&2 "merge: usage: merge [-p] file1 file2 file3" 16 exit 1 17esac 18 19case $p in 20w) 21 if test ! -w $1 22 then 23 echo >&2 "$1 not writeable" 24 exit 1 25 fi 26esac 27 28trap 's=$?; rm -f /tmp/d3a$$ /tmp/d3b$$; exit $s' 0 29trap exit 1 2 3 13 15 30umask 077 31 32$DIFF $1 $3 >/tmp/d3a$$ 33case $? in 340|1) ;; 35*) exit 36esac 37 38$DIFF $2 $3 >/tmp/d3b$$ 39case $? in 400|1) ;; 41*) exit 42esac 43 44{ 45 $DIFF3 -E /tmp/d3a$$ /tmp/d3b$$ $1 $2 $3 $4 $5 46 case $? in 47 0) ;; 48 1) echo >&2 merge: warning: 1 overlap during merge.;; 49 *) echo >&2 merge: warning: $? overlaps during merge. 50 esac 51 echo $p 52} | ed - $1 53