|
|
1.1 ! root 1: #! /bin/sh ! 2: # Three-way file merge. ! 3: # $Header: /usr/wft/RCS/SRC/RCS/merge,v 3.1 82/11/28 19:45:37 wft Exp $ ! 4: # use: merge [-p] file1 file2 file3 [mark1 mark3] ! 5: # Effect: incorporates all changes that lead from file2 to file3 into file1. ! 6: # Result goes to std. output if -p is present, into file1 otherwise. ! 7: # Overlapping changes are delimited as follows: ! 8: # <<<<<<< file1 ! 9: # lines in file1 ! 10: # ======= ! 11: # lines in file3 ! 12: # >>>>>>> file3 ! 13: # If mark1 and mark3 are given the delimiting lines <<<<.. and >>>>... ! 14: # contain mark1 and mark3 instead of the names of file1 and file3. ! 15: # A warning is printed if there are overlaps. ! 16: ! 17: PATH=/bin:/usr/bin:. ! 18: DIFF3=/usr/lib/diff3 ! 19: p=0 ! 20: case $1 in ! 21: -p) ! 22: p=$1 ! 23: shift;; ! 24: esac ! 25: ! 26: ! 27: if test $# -ge 3 ! 28: then ! 29: if test -f $1 -a -f $2 -a -f $3 ! 30: then ! 31: trap "rm -f /tmp/d3[abc]$$" 0 1 2 13 15 ! 32: diff $1 $3 >/tmp/d3a$$ ! 33: diff $2 $3 >/tmp/d3b$$ ! 34: $DIFF3 -E /tmp/d3[ab]$$ $1 $2 $3 $4 $5 > /tmp/d3c$$ ! 35: r=$? ! 36: if test $r != 0 ! 37: then ! 38: echo Warning: $r overlaps during merge. 1>&2 ! 39: fi ! 40: if test $p != 0 ! 41: then ! 42: (cat /tmp/d3c$$; echo '1,$p') | ed - $1 ! 43: else ! 44: (cat /tmp/d3c$$; echo w) | ed - $1 ! 45: fi ! 46: exit 0 ! 47: else ! 48: echo "Cannot open $1, $2, or $3" 1>&2 ! 49: fi ! 50: fi ! 51: echo "usage: merge [-p] file1 file2 file3" 1>&2 ! 52: exit 1
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.