diff options
author | classabbyamp <void@placeviolette.net> | 2022-09-02 04:51:49 -0400 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2022-09-02 16:04:03 +0200 |
commit | 8f5e62949a7ee88b85cf45a62617026549e3040a (patch) | |
tree | be6e1b1cf7397234a369961555f92cfce713846c /xpkgdiff | |
parent | d9a71e0c17a53c08420902ee482df45a2c1b8324 (diff) | |
download | xtools-8f5e62949a7ee88b85cf45a62617026549e3040a.tar.gz xtools-8f5e62949a7ee88b85cf45a62617026549e3040a.tar.xz xtools-8f5e62949a7ee88b85cf45a62617026549e3040a.zip |
xpkgdiff: clean up even on error
Diffstat (limited to 'xpkgdiff')
-rwxr-xr-x | xpkgdiff | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/xpkgdiff b/xpkgdiff index 9072b34..581366e 100755 --- a/xpkgdiff +++ b/xpkgdiff @@ -6,13 +6,15 @@ usage() { exit 1 } +cleanup() { + rm -rf $TMPDIR +} + : ${DIFF:="diff -u --color"} # by default, don't sort SORT='cat' -TMPDIR=$(mktemp --tmpdir -d "xpkgdiff.XXXXX") - while getopts Sc:fhp:rtx flag; do case $flag in S) QUERY='--show' ;; @@ -31,6 +33,10 @@ shift $(($OPTIND - 1)) [ "$#" -eq 0 ] && usage [ -z "$QUERY" ] && usage +TMPDIR=$(mktemp --tmpdir -d "xpkgdiff.XXXXX") + +trap cleanup EXIT INT TERM + if [ "$QUERY" = '--deps' ] && [ -n "$FULLTREE" ]; then QUERY='--fulldeptree --deps' fi @@ -80,5 +86,3 @@ else fi $DIFF $TMPDIR/$FILE1 $TMPDIR/$FILE2 - -rm -rf $TMPDIR |