From f1007ee0c6a2dfdc5512a1be3dada65cbc5d5391 Mon Sep 17 00:00:00 2001 From: rsc Date: Sun, 21 May 2006 18:39:29 +0000 Subject: new --- bin/upas/msgcat | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 bin/upas/msgcat (limited to 'bin/upas/msgcat') diff --git a/bin/upas/msgcat b/bin/upas/msgcat new file mode 100755 index 00000000..7067a435 --- /dev/null +++ b/bin/upas/msgcat @@ -0,0 +1,61 @@ +#!/usr/local/plan9/bin/rc + +fn read9p { + srv=$1; shift + 9p read $srv >[2=1]|grep -v '^9p\:' +} + +fn dir9p { + srv=$1; shift + 9p ls $srv >[2=1]|grep -v '^9p\:' +} + + +fn catmesg { + # hold on for a second + TMP=/tmp/$USER.`{date -n}; sleep 1 + msg=$1; + read9p $msg/body >$TMP.body + t=`{read9p $msg/type} + switch($t){ + case text/html + echo ' + ,x// c// + ,x/<[^>]+>/d + ,p + u + ,y/<[^>]+>/d + ,p + '| sam -d $TMP.body|[2] sed '1d;/^\?/d' + case text/* + cat $TMP.body + case message/* + cat $TMP.body + case multipart/related + if (~ `{read9p $msg/1/type} text/plain) + catmesg $msg/1 + if not if (~ `{read9p $msg/2/type} text/plain) + catmesg $msg/2 + if not { + for (i in `{dir9p $msg|awk '$10 ~ /[0-9][0-9]*/ {print $10}'}) + catmesg $msg/$i + } + case * + echo $t + # should there be more? + } + rm -f $TMP.body +} + +if (~ $#* 0) + echo usage: msgcat mail/mbox/msgn && exit 1 + +mesg=$1 +if (~ `{read9p $mesg/lines} '') + echo no such message $mesg && exit 2 + + +read9p $mesg/unixheader; read9p $mesg/header +echo +catmesg $mesg +echo -- cgit v1.2.3