diff options
Diffstat (limited to 'diffbas')
-rwxr-xr-x | diffbas | 56 |
1 files changed, 56 insertions, 0 deletions
@@ -0,0 +1,56 @@ +#!/bin/sh + +usage() { + cat <<EOF +Usage: $( basename $0 ) [diff-opts] [-- listbas-opts] file1.bas file2.bas + +Diff two tokenized Atari BASIC programs, using listbas(1) and diff(1). + +[diff-opts] is passed through as-is to diff. +[listbas-opts] is passed through as-is to listbas. +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 )".lst + elif [ "$file2" = "" ]; then + file2="$( realpath $i )" + base2="$( basename $i )".lst + else + usage 1 + fi + elif [ "$i" = "--" ]; then + opts="listbasopts" + elif [ "$opts" = "listbasopts" ]; then + listbasopts="$listbasopts $i" + else + diffopts="$diffopts $i" + fi +done + +dir="$( mktemp -d -t diffbas.XXXXXXXXXX )" +[ -d "$dir" ] +cd "$dir" +trap cleanup EXIT +set -e + +listbas $listbasopts "$file1" > $base1 +listbas $listbasopts "$file2" > $base2 +diff $diffopts $base1 $base2 + +exit 0 |