X-Git-Url: https://git.madduck.net/etc/mutt.git/blobdiff_plain/76227d1c302ee76d82c037e923c70edc61fd5aea..2e31cd732213c3d974089cad8e88ab2bb3ccf371:/.mutt/bgrun diff --git a/.mutt/bgrun b/.mutt/bgrun index e0bcd20..260925c 100755 --- a/.mutt/bgrun +++ b/.mutt/bgrun @@ -9,10 +9,10 @@ elif [ -d "${TMPDIR}/volatile" ]; then fi export TMPDIR TMPDIR=$(mktemp -dp "$TMPDIR" mutt.XXXXXXXXXX) -trap "rm -rf '$TMPDIR'" 1 2 3 4 5 6 7 8 10 11 12 13 14 15 +cleanup() { cd / && rm -rf "$TMPDIR"; } +trap cleanup 1 2 3 4 5 6 7 8 10 11 12 13 14 15 -BASENAME="${1##*/}" -TEMPFILE="${TMPDIR}/${BASENAME}" +cd "$TMPDIR" notify() { if [ -x "$(command -v awesome-client)" ]; then @@ -38,11 +38,11 @@ case "$SELF" in MIMETYPE="$2" ( run-mailcap --action=view "$MIMETYPE":"$TEMPFILE" - rm -rf "$TMPDIR" if [ -s "$TMPDIR/output.stdout" ] || [ -s "$TMPDIR/output.stderr" ]; then notify $TMPDIR/output.stdout $TMPDIR/output.stderr \ "Output from mutt/$SELF on $BASENAME" fi + cleanup ) & trap - 1 2 3 4 5 6 7 8 10 11 12 13 14 15 ;; @@ -55,6 +55,6 @@ case "$SELF" in cat "$INPUTFILE" > $TEMPFILE & sensible-browser "$TEMPFILE" > $TMPDIR/output.stdout 2> $TMPDIR/output.stderr wait + cleanup ;; esac -