aboutsummaryrefslogtreecommitdiff
path: root/diffbas
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-07-12 23:54:05 -0400
committerB. Watson <urchlay@slackware.uk>2024-07-12 23:54:05 -0400
commit69b2d8b0219bfa9a4cfab8bbabda6cd395aada97 (patch)
tree3604196c49384709e8b9284f0456c401e39e1841 /diffbas
parent42bed941bb768cef5637a391512578eb49c2bf27 (diff)
downloadbw-atari8-tools-69b2d8b0219bfa9a4cfab8bbabda6cd395aada97.tar.gz
regenerate man pages.
Diffstat (limited to 'diffbas')
-rwxr-xr-xdiffbas37
1 files changed, 20 insertions, 17 deletions
diff --git a/diffbas b/diffbas
index fe69304..b5160fe 100755
--- a/diffbas
+++ b/diffbas
@@ -12,7 +12,14 @@ EOF
exit "$1"
}
-if [ "$@" = "-h" -o "$@" = "--help" ]; then
+cleanup() {
+ if [ "$dir" != "" ]; then
+ cd
+ rm -rf "$dir"
+ fi
+}
+
+if [ "$1" = "-h" -o "$1" = "--help" -o "$1" = "" ]; then
usage 0
fi
@@ -20,8 +27,10 @@ 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
@@ -34,19 +43,13 @@ for i in "$@"; do
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"
+dir="$( mktemp -d -t diffbas.XXXXXXXXXX )"
+[ -d "$dir" ]
+cd "$dir"
+trap cleanup EXIT
+
+listbas $listbasopts "$file1" > $base1
+listbas $listbasopts "$file2" > $base2
+diff $diffopts $base1 $base2
+
+exit 0