Blob


1 # mquote
3 mquote - format MSG as a quotation.
5 This is a tweaked copy of mquote from mblaze that adds the date of the
6 original message.
8 #!/bin/sh
10 Extract the sender
12 : ${from:=$(mhdr -d -h x-original-from "$1")}
13 : ${from:=$(mhdr -d -h from "$1")}
14 : ${from:=Someone}
16 and the date
18 pfmt="%a, %d %b %Y %H:%M:%S %z"
19 : ${date:=$(mhdr -d -h date "$1")}
20 date="${date:+$(dateconv -f "$pfmt" "$date")}"
22 printf '%s%s wrote:\n' "${date:+On $date, }" "$from"
24 Then strip the signature, empty lines and prefix everything with ">"
26 { mshow -R "$1" || mshow -h '' -N "$1"; } |
27 sed -n '/^-- $/,$!p' |
28 sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' |
29 sed 's/^/> /'