blob: 38d44602c4469f1cd5b7912e5669ca642132f02d (
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
56
|
#!/bin/sh
usage() {
cat <<EOF
Usage: $( basename $0 ) [diff-opts] [-- a8cat-opts] file1 file2
Diff two Atari ATASCII files, using a8cat(1) and diff(1).
[diff-opts] is passed through as-is to diff.
[a8cat-opts] is passed through as-is to a8cat.
EOF
exit "$1"
}
cleanup() {
if [ "$dir" != "" ]; then
cd
rm -rf "$dir"
fi
}
if [ "$1" = "-h" -o "$1" = "--help" -o "$1" = "" ]; then
usage 0
fi
for i in "$@"; do
if [ -f "$i" ]; then
if [ "$file1" = "" ]; then
file1="$( realpath $i )"
base1="$( basename $i )".txt
elif [ "$file2" = "" ]; then
file2="$( realpath $i )"
base2="$( basename $i )".txt
else
usage 1
fi
elif [ "$i" = "--" ]; then
opts="a8catopts"
elif [ "$opts" = "a8catopts" ]; then
a8catopts="$a8catopts $i"
else
diffopts="$diffopts $i"
fi
done
dir="$( mktemp -d -t diffbas.XXXXXXXXXX )"
[ -d "$dir" ]
cd "$dir"
trap cleanup EXIT
set -e
a8cat $a8catopts "$file1" > $base1
a8cat $a8catopts "$file2" > $base2
diff $diffopts $base1 $base2
exit 0
|