home *** CD-ROM | disk | FTP | other *** search
/ BUG 1 / BUGCD1996_0708.ISO / pc / util / minilin / minilin.exe / USR / BIN / MESSAGES < prev    next >
Text File  |  1994-04-02  |  944b  |  42 lines

  1. #!/bin/sh
  2. # messages: part of the Elm mail system
  3. # @(#)$Id: messages.SH,v 5.2 1992/10/17 22:38:58 syd Exp $
  4. #        Copyright (c) 1988-1992 USENET Community Trust
  5. #         Copyright (c) 1986,1987 Dave Taylor
  6.  
  7. if [ "$2" != "" ]; then
  8.   echo Usage: messages \{folder-name\} 1>&2
  9.   exit 1
  10. fi
  11.  
  12. if [ "$1" = "" ]; then
  13.   fname=${MAIL-/var/spool/mail/$LOGNAME}
  14.   optional="in your incoming mailbox"
  15. else
  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
  24. fi
  25.  
  26. if [ -f "$fname" ]; then
  27.   mcount=`egrep -c "^From " $fname`
  28. else
  29.   echo "Folder $1 does not exist."
  30.   exit 0
  31. fi
  32.  
  33. if [ "$mcount" -eq 1 ]; then
  34.   echo There is 1 message $optional.
  35. elif [ "$mcount" -eq 0 ]; then
  36.   echo There are no messages $optional.
  37. else
  38.   echo There are $mcount messages $optional.
  39. fi
  40.  
  41. exit $mcount
  42.