]> git.madduck.net Git - etc/mailfilter.git/blob - bin/kill-from

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

add ctte to justme exceptions
[etc/mailfilter.git] / bin / kill-from
1 #!/bin/sh
2 set -eu
3
4 CONFIG_DIR="${0%/*}/../config"
5 IGNORE_FILE="$CONFIG_DIR/ignore"
6 ME="${0##*/}"
7
8 case "$ME" in
9   kill-from)
10     case "${1:-}" in
11       *@*) :;;
12       '') 
13         echo "E: missing email address argument." >&2
14         exit 1
15         ;;
16       *)
17         echo "E: not an email address: $1" >&2
18         exit 2
19         ;;
20     esac
21     CHECKPREFIX='From: someone <'
22     CHECKPOSTFIX='>'
23     REPREFIX='^From:.*\<'
24     REPOSTFIX='\>'
25     ARG="$1"
26     ;;
27   kill-thread)
28     case "${1:-}" in
29       *@*) :;;
30       '') 
31         echo "E: missing message ID argument." >&2
32         exit 1
33         ;;
34       *)
35         echo "E: not a message ID: $1" >&2
36         exit 2
37         ;;
38     esac
39     CHECKPREFIX='References: <something> <'
40     CHECKPOSTFIX='>'
41     REPREFIX='^References:.*\<'
42     REPOSTFIX='\>'
43     ARG="${1#<}"; ARG="${ARG%>}"
44     ;;
45 esac
46
47 if echo "$CHECKPREFIX$1$CHECKPOSTFIX" | egrep -qif $IGNORE_FILE; then
48   echo "I: already ignored: $1" >&2
49   exit 0
50 fi
51
52 ARG_ESCAPED="$(echo "$ARG" | sed -re 's,([.+]),\\\1,g')"
53 cat <<_eof >> $IGNORE_FILE
54 $^# added by $ME @$(date +%s)
55 $REPREFIX$ARG_ESCAPED$REPOSTFIX
56 _eof
57
58 cd $CONFIG_DIR
59 git-commit -m"$ME $1" ${IGNORE_FILE##*/}