aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-07-12 17:42:40 -0400
committerB. Watson <urchlay@slackware.uk>2024-07-12 17:42:40 -0400
commite1e0f8da7029dfb7cfb8303198337ad708235316 (patch)
treee7feee50837d7026ae1c25a02b8980227656518d
parent56c845d606881296de8db09d1bb8568f4a14934d (diff)
downloadbw-atari8-tools-e1e0f8da7029dfb7cfb8303198337ad708235316.tar.gz
diffbas: added (wrapper for listbas and diff).
-rwxr-xr-xdiffbas52
1 files changed, 52 insertions, 0 deletions
diff --git a/diffbas b/diffbas
new file mode 100755
index 0000000..fe69304
--- /dev/null
+++ b/diffbas
@@ -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"