[BACK]Return to diff3.ksh CVS log [TXT][DIR] Up to [local] / src / usr.bin / diff3

Annotation of src/usr.bin/diff3/diff3.ksh, Revision 1.1

1.1     ! millert     1: #!/bin/ksh -
        !             2: #
        !             3: # $OpenBSD$
        !             4: #
        !             5: # Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
        !             6: #
        !             7: # Permission to use, copy, modify, and distribute this software for any
        !             8: # purpose with or without fee is hereby granted, provided that the above
        !             9: # copyright notice and this permission notice appear in all copies.
        !            10: #
        !            11: # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
        !            12: # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
        !            13: # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
        !            14: # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
        !            15: # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
        !            16: # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
        !            17: # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
        !            18: #
        !            19: # Sponsored in part by the Defense Advanced Research Projects
        !            20: # Agency (DARPA) and Air Force Research Laboratory, Air Force
        !            21: # Materiel Command, USAF, under agreement number F39502-99-1-0512.
        !            22: #
        !            23:
        !            24: set -o posix           # set POSIX mode to prevent +foo in getopts
        !            25: OPTIND=1               # force getopts to reset itself
        !            26:
        !            27: export PATH=/bin:/usr/bin
        !            28: diff3prog=/usr/libexec/diff3prog
        !            29: USAGE="usage: diff3 [-aexEX3] file1 file2 file3"
        !            30:
        !            31: # Pull out any command line flags (some for diff, some for diff3)
        !            32: dflags=
        !            33: d3flags=
        !            34: while getopts "aeExX3" c; do
        !            35:        case "$c" in
        !            36:                a)
        !            37:                        dflags="$dflags $1"
        !            38:                        shift
        !            39:                        ;;
        !            40:                e|E|x|X|3)
        !            41:                        d3flags="-$c"
        !            42:                        shift
        !            43:                        ;;
        !            44:                *)
        !            45:                        echo "$USAGE" 1>&2
        !            46:                        exit 1
        !            47:                        ;;
        !            48:        esac
        !            49: done
        !            50: shift $(( $OPTIND - 1 ))
        !            51:
        !            52: TMP1=`mktemp -t d3a.XXXXXXXXXX` || exit 1
        !            53: TMP2=`mktemp -t d3b.XXXXXXXXXX`
        !            54: if [ $? -ne 0 ]; then
        !            55:        rm -f $TMP1
        !            56:        exit 1
        !            57: fi
        !            58: trap "/bin/rm -f $TMP1 $TMP2" 0 1 2 13 15
        !            59: diff $dflags $1 $3 > $TMP1
        !            60: diff $dflags $2 $3 > $TMP2
        !            61: $DIFF3PROG $d3flags $TMP1 $TMP2 $1 $2 $3
        !            62: exit $?