]> git.madduck.net Git - etc/mutt.git/blob - add-tickle-stamp

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 quoting issues when replacing the editor and restoring the setting
[etc/mutt.git] / add-tickle-stamp
1 #!/bin/sh
2 set -eu
3
4 file=/dev/stdin
5 if [ -r "${1:-}" ] && [ -w "${1:-}" ]; then
6   file="$1"
7   shift
8 fi
9
10 date=
11 arg="${1:-}"
12 args="$*"
13 if [ -z "$arg" ]; then
14   read -p 'When should I tickle you about this message? ' args
15   arg="${args%% *}"
16 fi
17
18 if [ "$arg" = '-d' ] || [ $# -gt 1 ]; then
19   shift
20   date="$args"
21 else
22   case "$arg" in
23     *[0-9]w) date="now + ${arg%w} weeks 00:00";;
24     *[0-9]m) date="now + ${arg%m} months 00:00";;
25     *[0-9]h) date="now + ${arg%h} hours";;
26     *[0-9]d) date="now + ${arg%d} days 00:00";;
27     *' '*) date="$args";;
28     *[!0-9]*) 
29       echo "E: invalid argument: $arg" >&2
30       exit 1
31       ;;
32     *) date="now + $arg days 00:00";;
33   esac
34 fi
35
36 tickle=$(date +'%s (%c)' -d "$date")
37
38 TMPFILE="$(tempfile -d /tmp -p tickle)"
39 trap "rm -f $TMPFILE" 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15
40
41 formail -i "X-Tickle: $tickle" < $file > $TMPFILE
42
43 [ -w "$file" ] && mv $TMPFILE $file
44
45 rm -f $TMPFILE
46 trap - 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15