From: martin f. krafft Date: Thu, 9 Sep 2021 02:58:38 +0000 (+1200) Subject: migrate from tempfile to mktemp X-Git-Url: https://git.madduck.net/etc/mutt.git/commitdiff_plain/f1ab8bcb3d0102fe44d2baad1de229f3edce4048?ds=inline;hp=b2f281d78c0fa6ff0a92901a603098df6a5e57b2 migrate from tempfile to mktemp --- diff --git a/.mutt/bgrun b/.mutt/bgrun index c19920f..ad432df 100755 --- a/.mutt/bgrun +++ b/.mutt/bgrun @@ -83,7 +83,7 @@ guess_extension() { get_file() { local t if [ -z "$1" ]; then - t=$(TMPDIR="$PWD" tempfile -s $(guess_extension "$MIMETYPE")) + t=$(mktemp -p "$PWD" tmp.XXXXXXXXXX.$(guess_extension "$MIMETYPE")) cat > "$t" echo "$t" else diff --git a/.mutt/filter-proxy b/.mutt/filter-proxy index a2cf580..e0b1ad2 100755 --- a/.mutt/filter-proxy +++ b/.mutt/filter-proxy @@ -21,7 +21,7 @@ while [ -n "${1:-}" ]; do shift done -TMPFILE="$(tempfile -p proxy)" +TMPFILE="$(mktemp --tmpdir proxy.XXXXXXXXXX)" trap "rm -f $TMPFILE" 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 eval $cmd <"$file" >$TMPFILE diff --git a/.mutt/reuse-message b/.mutt/reuse-message index 0bdb3f8..0d8ed23 100755 --- a/.mutt/reuse-message +++ b/.mutt/reuse-message @@ -11,7 +11,7 @@ for i in "$@"; do esac done -tmpfile=$(tempfile -p reuse) +tmpfile=$(mktemp --tmpdir reuse.XXXXXXXXXX) cleanup() { rm -f "$tmpfile"; trap - 1 2 3 4 5 6 7 8 10 11 12 13 14 15; } trap cleanup 1 2 3 4 5 6 7 8 10 11 12 13 14 15 diff --git a/.mutt/sendmail b/.mutt/sendmail index b125941..80fd4a1 100755 --- a/.mutt/sendmail +++ b/.mutt/sendmail @@ -10,12 +10,12 @@ # Copyright © 2010 martin f. krafft # Released under the terms of the Artistic Licence 2.0 # -set -eu +set -eux CHECKSDIR="$HOME/.mutt/sendmail-checks.d" SENDMAIL="/usr/sbin/sendmail -oem -oi" -TMPFILE=$(tempfile -p mutt-sendmail -s .msg) +TMPFILE=$(mktemp --tmpdir mutt-sendmail.XXXXXXXXXX.msg) settrap () { trap "$@" 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15; } cleanup () { rm -f "$TMPFILE"; settrap -; } settrap cleanup diff --git a/.mutt/sendmail-checks.d/ack-recipients b/.mutt/sendmail-checks.d/ack-recipients index d341964..749b1d6 100755 --- a/.mutt/sendmail-checks.d/ack-recipients +++ b/.mutt/sendmail-checks.d/ack-recipients @@ -43,7 +43,7 @@ done [ $ret -eq 0 ] || exit $ret # now remove the X-Acked header from the mail -TMPFILE=$(tempfile -p mutt-sendmail -s .msg) +TMPFILE=$(mktemp --tmpdir mutt-sendmail.XXXXXXXXXX.msg) settrap () { trap "$@" 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15; } cleanup () { rm -f "$TMPFILE"; settrap -; } settrap cleanup diff --git a/.mutt/sendmail-checks.d/zzz_add-spool-bcc b/.mutt/sendmail-checks.d/zzz_add-spool-bcc index f9f7cbf..d085679 100755 --- a/.mutt/sendmail-checks.d/zzz_add-spool-bcc +++ b/.mutt/sendmail-checks.d/zzz_add-spool-bcc @@ -15,7 +15,7 @@ DEST="$SPOOL_MAILDIR/cur/${INPUT##*/}:2,S" if ! cp -n "$INPUT" "$DEST"; then echo >&1 "W: failed to spool message file '$1'." - TMPFILE=$(tempfile -p mutt-sendmail -s .msg) + TMPFILE=$(mktemp --tmpdir mutt-sendmail.XXXXXXXXXX.msg) echo >&1 "W: leaving a copy in '$TMPFILE'…" else RECIPIENTS=$(for i in "$@"; do echo -n " $i,"; done)