aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-08-26 16:57:13 -0400
committerB. Watson <urchlay@slackware.uk>2026-08-26 16:57:13 -0400
commit9d7e3b4b8e35469fd2bded70e0ee473e4afc46de (patch)
tree9d92ac617c6ed185e8a6f1160bb4e32b71a770fd
parent5e3ad97b79980d285054e0ac0052f86b1076a4df (diff)
downloadmisc-scripts-9d7e3b4b8e35469fd2bded70e0ee473e4afc46de.tar.gz
litterbox: use mktemp; do not double-compress .zip or .gz files.
-rwxr-xr-xlitterbox8
1 files changed, 8 insertions, 0 deletions
diff --git a/litterbox b/litterbox
index c60e35c..1159de9 100755
--- a/litterbox
+++ b/litterbox
@@ -9,6 +9,8 @@ URLS=""
EXPIRE="1"
DELAY="${DELAY:-2}"
UPLOAD_COUNT=0
+TMP="$( mktemp -t -d $SELF.XXXXXXXXXX )"
+trap cleanup EXIT
die() {
echo "$SELF: fatal: $@" 1>&2
@@ -27,6 +29,10 @@ check_path() {
type -p "$1" &>/dev/null
}
+cleanup() {
+ [ "$TMP" != "" ] && rm -rf "$TMP"
+}
+
usage() {
if ! check_path perldoc; then
warn "can't find perldoc on PATH, printing raw POD."
@@ -127,6 +133,8 @@ upload_file() {
*.exe|*.scr|*.cpl|*.doc*|*.jar)
warn "forbidden file extension, compression forced"
use_compression=1 ;;
+ *.zip|*.gz)
+ use_compression=0 ;;
*)
use_compression="$COMPRESS" ;;
esac