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:

fix resubmit script argument processing
[etc/mailfilter.git] / bin / resubmit
1 #!/bin/sh
2 set -eu
3
4 ME="${0##*/}"
5
6 about()
7 {
8   echo "$ME -- resubmit messages to the mail filter"
9   echo "Copyright © martin f. krafft <madduck@madduck.net>"
10   echo "Released under the terms of the Artistic Licence 2.0"
11 }
12
13 usage()
14 {
15   echo "Usage: $ME [options] <Maildir> [<Maildir> ...]"
16   echo
17   echo "Valid options are:"
18   cat <<-_eof | column -s\& -t
19         -V|--version & show version information.
20         -h|--help & show this output.
21         -l|--list & process the argument list (even if empty), never stdin
22         _eof
23 }
24
25 SHORTOPTS=Vhl
26 LONGOPTS=version,help,list
27
28 list=0
29 files=
30
31 for opt in $(getopt -n $ME -o $SHORTOPTS -l $LONGOPTS -u -- "$@"); do
32   case "$opt" in
33     -V|--version) about; exit 0;;
34     -h|--help) about; echo; usage; exit 0;;
35     -l|--list) list=1;;
36     --) :;;
37     *)
38       if [ -f "$opt" ] && [ -r "$opt" ]; then
39         files="$files $opt"
40       else
41         echo "E: unknown argument: $opt" >&2
42         exit 1
43       fi
44       ;;
45   esac
46 done
47
48 PROCMAIL=$HOME/.etc/mailfilter/procmail/procmailrc
49 # execute the date -R only during the eval, not immediately
50 FILTER='/usr/bin/formail -I"X-Resubmitted: $(date -R)"'
51
52 if [ -z "${files:-}" ] && [ $list -eq 0 ]; then
53   eval $FILTER | exec $PROCMAIL
54 else
55   for f in $files; do
56     eval $FILTER < "$f" | $PROCMAIL && rm -f "$f"
57   done
58 fi
59
60 exit 0