5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
27 # Copyright (c) 1999, 2001 by Sun Microsystems, Inc.
28 # All rights reserved.
30 #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.4 */
32 usage
="usage: diff3 file1 file2 file3"
34 # mktmpdir - Create a private (mode 0700) temporary directory inside of /tmp
35 # for this process's temporary files. We set up a trap to remove the
36 # directory on exit (trap 0), and also on SIGHUP, SIGINT, SIGQUIT, SIGPIPE,
41 trap '/usr/bin/rm -rf $tmpdir' 0 1 2 3 13 15
42 /usr
/bin
/mkdir
-m 700 $tmpdir ||
exit 1
56 if [ \
( -f $1 -o -c $1 \
) -a \
( -f $2 -o -c $2 \
) -a \
( -f $3 -o -c $3 \
) ]; then
65 /usr
/bin
/cat $f1 > $tmpdir/d3c$$
70 /usr
/bin
/cat $f2 > $tmpdir/d3d$$
75 /usr
/bin
/cat $f3 > $tmpdir/d3e$$
79 /usr
/bin
/diff $f1 $f3 > $tmpdir/d3a$$
2> $tmpdir/d3a$$.err
83 grep -q "^[<>]" $tmpdir/d3a$$
87 /usr
/bin
/cat $tmpdir/d3a$$
93 echo "diff3 failed" 1>&2
100 /usr
/bin
/cat $tmpdir/d3a$$.err
104 /usr
/bin
/diff $f2 $f3 > $tmpdir/d3b$$
2> $tmpdir/d3b$$.err
108 grep -q "^[<>]" $tmpdir/d3b$$
112 /usr
/bin
/cat $tmpdir/d3b$$
118 echo "diff3 failed" 1>&2
125 /usr
/bin
/cat $tmpdir/d3b$$.err
129 /usr
/lib
/diff3prog
$e $tmpdir/d3
[ab
]$$
$f1 $f2 $f3