summaryrefslogtreecommitdiff
path: root/src/bin/eet/diffeet
blob: eed785b3ebac4b8f0fdb286603ccc12305078ef9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh

DIFF=${DIFF-diff}

cleanup() {
    if [ ! -z "$TDIR" ]; then
        rm -r "$TDIR"
    fi
}

die() {
    echo "$@"
    echo "Aborting"
    cleanup
    exit 1
}

usage() {
    die "Usage: diffeet <eet file> <eet file2> <section>"
}

decode_eet() {
    eet -d "$1" "$SECTION" "$2"

    if [ $? -ne 0 ]; then
        die "Failed decoding eet file '$1'."
    fi
}

EETFILE1="$1"
EETFILE2="$2"
SECTION="$3"

if [ $# -ne 3 ]; then
    usage
fi

TDIR=$(mktemp -d)

if [ $? -ne 0 ]; then
    die "Failed creating tempdir."
fi

TMP="$(basename $EETFILE1)"
TARGET1="$TDIR/$TMP"
TMP="$(basename $EETFILE2)"
TARGET2="$TDIR/$TMP"

# Decode the file
decode_eet "$EETFILE1" "$TARGET1"
decode_eet "$EETFILE2" "$TARGET2"

$DIFF "$TARGET1" "$TARGET2"

cleanup