#!/usr/bin/sh # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License, Version 1.0 only # (the "License"). You may not use this file except in compliance # with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T # All Rights Reserved # Copyright (c) 1999, 2001 by Sun Microsystems, Inc. # All rights reserved. #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.4 */ setvar usage = ""usage: diff3 file1 file2 file3"" # mktmpdir - Create a private (mode 0700) temporary directory inside of /tmp # for this process's temporary files. We set up a trap to remove the # directory on exit (trap 0), and also on SIGHUP, SIGINT, SIGQUIT, SIGPIPE, # and SIGTERM. proc mktmpdir { setvar tmpdir = "/tmp/diff3.$Pid" trap '/usr/bin/rm -rf $tmpdir' 0 1 2 3 13 15 /usr/bin/mkdir -m 700 $tmpdir || exit 1 } mktmpdir setvar e = '' match $1 { with -* setvar e = "$1" shift } if test $Argc != 3 { echo ${usage} 1>&2 exit 1 } if test '(' -f $1 -o -c $1 ')' -a '(' -f $2 -o -c $2 ')' -a '(' -f $3 -o -c $3 ')' { : } else { echo ${usage} 1>&2 exit 1 } setvar f1 = "$1", f2 = "$2", f3 = "$3" if test -c $f1 { /usr/bin/cat $f1 > $tmpdir/d3c$$ setvar f1 = "$tmpdir/d3c$Pid" } if test -c $f2 { /usr/bin/cat $f2 > $tmpdir/d3d$$ setvar f2 = "$tmpdir/d3d$Pid" } if test -c $f3 { /usr/bin/cat $f3 > $tmpdir/d3e$$ setvar f3 = "$tmpdir/d3e$Pid" } /usr/bin/diff $f1 $f3 > $tmpdir/d3a$$ 2> $tmpdir/d3a$$.err setvar STATUS = "$Status" if test $STATUS -eq 1 { /usr/xpg4/bin/grep -q "^[<>]" $tmpdir/d3a$Pid setvar RET = "$Status" if test $RET -eq 1 { /usr/bin/cat $tmpdir/d3a$Pid exit $STATUS } if test $RET -gt 1 { echo "diff3 failed" 1>&2 exit $STATUS } } if test $STATUS -gt 1 { /usr/bin/cat $tmpdir/d3a$Pid.err exit $STATUS } /usr/bin/diff $f2 $f3 > $tmpdir/d3b$$ 2> $tmpdir/d3b$$.err setvar STATUS = "$Status" if test $STATUS -eq 1 { /usr/xpg4/bin/grep -q "^[<>]" $tmpdir/d3b$Pid setvar RET = "$Status" if test $RET -eq 1 { /usr/bin/cat $tmpdir/d3b$Pid exit $STATUS } if test $RET -gt 1 { echo "diff3 failed" 1>&2 exit $STATUS } } if test $STATUS -gt 1 { /usr/bin/cat $tmpdir/d3b$Pid.err exit $STATUS } /usr/lib/diff3prog $e $tmpdir/d3[ab]$Pid $f1 $f2 $f3