~dricottone/mail-filters

1d95aa9263475e71c60b26f2ea38bff998ed19d4 — Dominic Ricottone 2 years ago b1a1f1c dev
Removing wrapper

I changed my mind about gracefully failing to use digestion. It's just
best to make it a hard dependency.
2 files changed, 6 insertions(+), 26 deletions(-)

M README.md
D src/mailman.sh
M README.md => README.md +6 -10
@@ 35,9 35,9 @@ to,~.@lists.ubuntu.com        =/usr/local/bin/parcels
to,~.@lists.debian.org        =/usr/local/bin/parcels | /usr/local/share/mail-filters/debian.awk
from,~.@freebsd.org           =/usr/local/bin/parcels | /usr/local/share/mail-filters/freebsd.awk
from,~.+@googlegroups.com     =/usr/local/bin/parcels | /usr/local/share/mail-filters/googlegroups.awk
from,~.+@lists.archlinux.org  =/usr/local/share/mail-filters/mailman.sh
from,~.+@python.org           =/usr/local/share/mail-filters/mailman.sh
from,~.+@gnu.org              =/usr/local/share/mail-filters/mailman.sh
from,~.+@lists.archlinux.org  =/usr/local/bin/digestion
from,~.+@python.org           =/usr/local/bin/digestion
from,~.+@gnu.org              =/usr/local/bin/digestion
text/*                        =/usr/local/bin/parcels
```



@@ 71,11 71,11 @@ elif grep --quiet -e '^From:.*@freebsd.org' "$TMP"; then
elif grep --quiet -e '^From:.*@googlegroups.com' "$TMP"; then
  cat "$TMP" | /usr/local/bin/parcels | /usr/local/share/mail-filters/googlegroups.awk
elif grep --quiet -e '^From:.*@archlinux.org' "$TMP"; then
  cat "$TMP" | /usr/local/share/mail-filters/mailman.sh
  cat "$TMP" | /usr/local/bin/digestion
elif grep --quiet -e '^From:.*@python.org' "$TMP"; then
  cat "$TMP" | /usr/local/share/mail-filters/mailman.sh
  cat "$TMP" | /usr/local/bin/digestion
elif grep --quiet -e '^From:.*@gnu.org' "$TMP"; then
  cat "$TMP" | /usr/local/share/mail-filters/mailman.sh
  cat "$TMP" | /usr/local/bin/digestion
else
  cat "$TMP" | /usr/local/bin/parcels
fi


@@ 83,10 83,6 @@ fi
rm -f "$TMP"
```

`mailman.sh` is a simple wrapper around `digestion` that gracefully handles the
that binary being unavailable. Meanwhile `parcels` is critical to using these
mail filters, so it is mandatory.

## License

All materials of this repository are licensed under BSD-3. A copy is included

D src/mailman.sh => src/mailman.sh +0 -16
@@ 1,16 0,0 @@
#!/bin/sh

# mailman.sh
# ==========
# A filter (as for mutt or aerc) which runs digestion and an awk filter.

DIGESTION_INSTALL_DIR=/usr/local/bin
MAILFILTERS_INSTALL_DIR=/usr/local/share/mail-filters

if command -v $DIGESTION_INSTALL_DIR/digestion 2>&1 >/dev/null; then
  $DIGESTION_INSTALL_DIR/digestion -length $(tput cols) \
    | $MAILFILTERS_INSTALL_DIR/mailman.awk
else
  $MAILFILTERS_INSTALL_DIR/mailman.awk
fi