#!/bin/rc #TODO: # make case folding (grep -i) optional. # make what to search (from/to/cc/subject/body) optional? rfork e msgs=() # find a text part of a multipart message (or punt) fn findbody { for (subpart in `{walk | grep '/type$'}) { if (~ `{cat $subpart} text/*) multipart=($multipart `{basename -d $subpart}^/body) } if (~ $#multipart 0) echo body if not echo $multipart } # for each argument, find matching message numbers. for (arg in $*) for (i in *) { body=body multipart=() if (~ `{cat $i/type >[2] /dev/null} multipart/*) body=`{cd $i && findbody} if (grep -is $arg $i/$body $i/subject >[2] /dev/null) msgs=($msgs $i) } if (! ~ $#msgs 0) { plumb `{pwd}^/$msgs }