diff options
-rwxr-xr-x | diffbas | 52 |
1 files changed, 52 insertions, 0 deletions
@@ -0,0 +1,52 @@ +#!/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" +} + +if [ "$@" = "-h" -o "$@" = "--help" ]; then + usage 0 +fi + +for i in "$@"; do + if [ -f "$i" ]; then + if [ "$file1" = "" ]; then + file1="$( realpath $i )" + elif [ "$file2" = "" ]; then + file2="$( realpath $i )" + else + usage 1 + fi + elif [ "$i" = "--" ]; then + opts="listbasopts" + elif [ "$opts" = "listbasopts" ]; then + listbasopts="$diffopts $i" + else + diffopts="$listbasopts $i" + fi +done + +## cat <<EOF +## file1: $file1 +## file2: $file2 +## listbasopts: $listbasopts +## diffopts: $diffopts +## EOF +## exit 0 + +dir="$( mktemp -d )" +[ -d "$dir" ] || exit 1 +cd "$dir" || exit 1 +listbas $listbasopts "$file1" > 1 +listbas $listbasopts "$file2" > 2 +diff $diffopts 1 2 +cd +rm -rf "$dir" |