xref: /386bsd/usr/local/bin/messages (revision a2142627)
1: use /bin/sh
2# messages: part of the Elm mail system
3# @(#)$Id: messages.SH,v 1.3 1993/10/09 19:41:10 smace Exp $
4#		Copyright (c) 1988-1992 USENET Community Trust
5# 		Copyright (c) 1986,1987 Dave Taylor
6
7if [ "$2" != "" ]; then
8  echo Usage: messages \{folder-name\} 1>&2
9  exit 1
10fi
11
12if [ "$1" = "" ]; then
13  fname=${MAIL-/var/mail/$LOGNAME}
14  optional="in your incoming mailbox"
15else
16  optional="in folder $1"
17  first=`expr "$1" : "\(.\).*"`
18  if [ "$first" = "=" ]; then
19    last=`expr "$1" : ".\(.*\)"`
20    fname="`grep maildir $HOME/.elm/elmrc | awk -F= '{print $2}'| tr -d ' '`/$last"
21  else
22    fname=$1
23  fi
24fi
25
26if [ -f "$fname" ]; then
27  mcount=`egrep -c "^From " $fname`
28else
29  echo "Folder $1 does not exist."
30  exit 0
31fi
32
33if [ "$mcount" -eq 1 ]; then
34  echo There is 1 message $optional.
35elif [ "$mcount" -eq 0 ]; then
36  echo There are no messages $optional.
37else
38  echo There are $mcount messages $optional.
39fi
40
41exit $mcount
42