#!/bin/sh
# messages: part of the Elm mail system
# @(#)$Id: messages.SH,v 5.2 1992/10/17 22:38:58 syd Exp $
#		Copyright (c) 1988-1992 USENET Community Trust
# 		Copyright (c) 1986,1987 Dave Taylor

# v. 1.0.0 Modified to work under Bad Penguin by AGX
# v. 1.0.2 ... and also adjusted some bug. :-) 
# v. 1.0.4 ... and removed unused/unusefull stuffs (19991028)

# Count
fname=${MAIL-/var/spool/mail/$LOGNAME}
if [ -f "$fname" ]; then
  mcount=`egrep -c "^From " $fname`
else
  echoc RED "La cartella $fname non esiste."
  echoc RED "Per favore, contatta il tuo system administrator."  
  exit 0
fi

# Display
if [ "$mcount" -eq 1 ]; then
  echoc GREEN "*** C'e' solo un messaggio nella tua mailbox ***"
elif [ "$mcount" -eq 0 ]; then
  echo "Non ci sono messaggi nella tua mailbox"
else
  echoc GREEN "*** Ci sono $mcount messaggi nella tua mailbox ***"
fi
exit $mcount
