X-Git-Url: https://git.madduck.net/etc/mutt.git/blobdiff_plain/57c899814e74bdf9adec4c7d8211fc25d6b39697..62090a10f51ee6ec80a6385dde9cb41c8f2b2089:/.mutt/reuse-message?ds=inline diff --git a/.mutt/reuse-message b/.mutt/reuse-message index c833bd3..0d8ed23 100755 --- a/.mutt/reuse-message +++ b/.mutt/reuse-message @@ -2,15 +2,16 @@ set -eu eval mailfile="\${$#}" +editor= for i in "$@"; do # strip last argument from editor, yuk case "$i" in - ($mailfile) break;; + ("$mailfile") break;; (*) editor="${editor:+$editor }$i";; 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 @@ -20,8 +21,12 @@ formail -I Subject: < "$mailfile" | \ sed -e '/^Bcc:/aSubject: ' > "$tmpfile" cat "$tmpfile" > "$mailfile" +cleanup + if [ -n "$editor" ]; then eval exec "$editor" "$mailfile" + +# the last three replicate mutt's default (cf. manual) elif [ -n "$VISUAL" ]; then eval exec "$VISUAL" "$mailfile" elif [ -n "$EDITOR" ]; then