diff options
Diffstat (limited to 'diffbas')
-rwxr-xr-x | diffbas | 37 |
1 files changed, 20 insertions, 17 deletions
@@ -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 |