#! /bin/sh
###############################################################################
#
#  $Id: from,v 1.2 1997/12/11 17:42:46 bcwhite Exp $
#
#  'from' for filtered mailboxes
#
#  Written by: Behan Webster <behanw@pobox.com>
#


#
# Extract MAILDIR from the procmailrc files...
#
for rcfile in /etc/procmailrc $HOME/.procmailrc; do
    if [ -r $rcfile ]; then
        eval `sed -n -e 's/#.*$//' -e '/^[A-Z_]*=/p' $rcfile`
    fi
done

if [ -z "$MAILDIR" ]; then
    echo "$0: MAILDIR is not set" >&2
    exit 1;
fi


#
# Go to mail directory
#
cd $MAILDIR


#
# Locate all the mailbox files (may be in sub-directories)
#
mboxlist=`find . \( -name ".??*" -prune \) -o -type f ! -name ".*" -print | sed -e 's|^./||' | sort`


#
# Tell the user what messages are available
#
grep -c "^From " $mboxlist non-existant-mailbox 2>/dev/null | awk -F: '{ if ( $2 > 0 ) printf("%-4d%s\n", $2, $1) }'


#
# We're outta here...
#
exit 0
