diff options
Diffstat (limited to 'a8diff')
-rwxr-xr-x | a8diff | 56 |
1 files changed, 56 insertions, 0 deletions
@@ -0,0 +1,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 |