1*0Sstevel@tonic-gate#!/usr/bin/sh 2*0Sstevel@tonic-gate# 3*0Sstevel@tonic-gate# CDDL HEADER START 4*0Sstevel@tonic-gate# 5*0Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6*0Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only 7*0Sstevel@tonic-gate# (the "License"). You may not use this file except in compliance 8*0Sstevel@tonic-gate# with the License. 9*0Sstevel@tonic-gate# 10*0Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11*0Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 12*0Sstevel@tonic-gate# See the License for the specific language governing permissions 13*0Sstevel@tonic-gate# and limitations under the License. 14*0Sstevel@tonic-gate# 15*0Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 16*0Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17*0Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 18*0Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 19*0Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 20*0Sstevel@tonic-gate# 21*0Sstevel@tonic-gate# CDDL HEADER END 22*0Sstevel@tonic-gate# 23*0Sstevel@tonic-gate# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T 24*0Sstevel@tonic-gate# All Rights Reserved 25*0Sstevel@tonic-gate 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate# Copyright (c) 1999, 2001 by Sun Microsystems, Inc. 28*0Sstevel@tonic-gate# All rights reserved. 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.4 */ 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gateusage="usage: diff3 file1 file2 file3" 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gate# mktmpdir - Create a private (mode 0700) temporary directory inside of /tmp 35*0Sstevel@tonic-gate# for this process's temporary files. We set up a trap to remove the 36*0Sstevel@tonic-gate# directory on exit (trap 0), and also on SIGHUP, SIGINT, SIGQUIT, SIGPIPE, 37*0Sstevel@tonic-gate# and SIGTERM. 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gatemktmpdir() { 40*0Sstevel@tonic-gate tmpdir=/tmp/diff3.$$ 41*0Sstevel@tonic-gate trap '/usr/bin/rm -rf $tmpdir' 0 1 2 3 13 15 42*0Sstevel@tonic-gate /usr/bin/mkdir -m 700 $tmpdir || exit 1 43*0Sstevel@tonic-gate} 44*0Sstevel@tonic-gatemktmpdir 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gatee= 47*0Sstevel@tonic-gatecase $1 in 48*0Sstevel@tonic-gate-*) 49*0Sstevel@tonic-gate e=$1 50*0Sstevel@tonic-gate shift;; 51*0Sstevel@tonic-gateesac 52*0Sstevel@tonic-gateif [ $# != 3 ]; then 53*0Sstevel@tonic-gate echo ${usage} 1>&2 54*0Sstevel@tonic-gate exit 1 55*0Sstevel@tonic-gatefi 56*0Sstevel@tonic-gateif [ \( -f $1 -o -c $1 \) -a \( -f $2 -o -c $2 \) -a \( -f $3 -o -c $3 \) ]; then 57*0Sstevel@tonic-gate : 58*0Sstevel@tonic-gateelse 59*0Sstevel@tonic-gate echo ${usage} 1>&2 60*0Sstevel@tonic-gate exit 1 61*0Sstevel@tonic-gatefi 62*0Sstevel@tonic-gatef1=$1 f2=$2 f3=$3 63*0Sstevel@tonic-gateif [ -c $f1 ] 64*0Sstevel@tonic-gatethen 65*0Sstevel@tonic-gate /usr/bin/cat $f1 > $tmpdir/d3c$$ 66*0Sstevel@tonic-gate f1=$tmpdir/d3c$$ 67*0Sstevel@tonic-gatefi 68*0Sstevel@tonic-gateif [ -c $f2 ] 69*0Sstevel@tonic-gatethen 70*0Sstevel@tonic-gate /usr/bin/cat $f2 > $tmpdir/d3d$$ 71*0Sstevel@tonic-gate f2=$tmpdir/d3d$$ 72*0Sstevel@tonic-gatefi 73*0Sstevel@tonic-gateif [ -c $f3 ] 74*0Sstevel@tonic-gatethen 75*0Sstevel@tonic-gate /usr/bin/cat $f3 > $tmpdir/d3e$$ 76*0Sstevel@tonic-gate f3=$tmpdir/d3e$$ 77*0Sstevel@tonic-gatefi 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate/usr/bin/diff $f1 $f3 > $tmpdir/d3a$$ 2> $tmpdir/d3a$$.err 80*0Sstevel@tonic-gateSTATUS=$? 81*0Sstevel@tonic-gateif [ $STATUS -eq 1 ] 82*0Sstevel@tonic-gatethen 83*0Sstevel@tonic-gate /usr/xpg4/bin/grep -q "^[<>]" $tmpdir/d3a$$ 84*0Sstevel@tonic-gate RET=$? 85*0Sstevel@tonic-gate if [ $RET -eq 1 ] 86*0Sstevel@tonic-gate then 87*0Sstevel@tonic-gate /usr/bin/cat $tmpdir/d3a$$ 88*0Sstevel@tonic-gate exit $STATUS 89*0Sstevel@tonic-gate fi 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate if [ $RET -gt 1 ] 92*0Sstevel@tonic-gate then 93*0Sstevel@tonic-gate echo "diff3 failed" 1>&2 94*0Sstevel@tonic-gate exit $STATUS 95*0Sstevel@tonic-gate fi 96*0Sstevel@tonic-gatefi 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gateif [ $STATUS -gt 1 ] 99*0Sstevel@tonic-gatethen 100*0Sstevel@tonic-gate /usr/bin/cat $tmpdir/d3a$$.err 101*0Sstevel@tonic-gate exit $STATUS 102*0Sstevel@tonic-gatefi 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gate/usr/bin/diff $f2 $f3 > $tmpdir/d3b$$ 2> $tmpdir/d3b$$.err 105*0Sstevel@tonic-gateSTATUS=$? 106*0Sstevel@tonic-gateif [ $STATUS -eq 1 ] 107*0Sstevel@tonic-gatethen 108*0Sstevel@tonic-gate /usr/xpg4/bin/grep -q "^[<>]" $tmpdir/d3b$$ 109*0Sstevel@tonic-gate RET=$? 110*0Sstevel@tonic-gate if [ $RET -eq 1 ] 111*0Sstevel@tonic-gate then 112*0Sstevel@tonic-gate /usr/bin/cat $tmpdir/d3b$$ 113*0Sstevel@tonic-gate exit $STATUS 114*0Sstevel@tonic-gate fi 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate if [ $RET -gt 1 ] 117*0Sstevel@tonic-gate then 118*0Sstevel@tonic-gate echo "diff3 failed" 1>&2 119*0Sstevel@tonic-gate exit $STATUS 120*0Sstevel@tonic-gate fi 121*0Sstevel@tonic-gatefi 122*0Sstevel@tonic-gate 123*0Sstevel@tonic-gateif [ $STATUS -gt 1 ] 124*0Sstevel@tonic-gatethen 125*0Sstevel@tonic-gate /usr/bin/cat $tmpdir/d3b$$.err 126*0Sstevel@tonic-gate exit $STATUS 127*0Sstevel@tonic-gatefi 128*0Sstevel@tonic-gate 129*0Sstevel@tonic-gate/usr/lib/diff3prog $e $tmpdir/d3[ab]$$ $f1 $f2 $f3 130