home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Shells / zsh-3.0.5-MIHS / src / Functions / checkmail < prev    next >
Encoding:
Paul Falstad's zsh script  |  1996-10-10  |  838 b   |  29 lines

  1. #! /usr/local/bin/zsh
  2. #
  3. # This autoloadable function checks the folders specified as arguments
  4. # for new mails.  The arguments are interpeted in exactly the same way
  5. # as the mailpath special zsh parameter (see zshparam(1)).
  6. #
  7. # If no arguments are given mailpath is used.  If mailpath is empty, $MAIL
  8. # is used and if that is also empty, /var/spool/mail/$LOGNAME is used.
  9. # This function requires zsh-3.0.1 or newer.
  10. #
  11. # ZoltÆn HidvØgi <hzoli@cs.elte.hu>
  12. #
  13.  
  14. local file message
  15.  
  16. for file in "${@:-${mailpath[@]:-${MAIL:-/var/spool/mail/$LOGNAME}}}"
  17. do
  18.     message="${${(M)file%%\?*}#\?}"
  19.     file="${file%%\?*}"
  20.     if [[ -d "$file" ]] then
  21.         file=( "$file"/**/*(.ND) )
  22.         if (($#file)) then
  23.             checkmail "${^file}\?$message"
  24.         fi
  25.     elif test -N "$file"; then  # this also sets $_ to $file
  26.         print -r -- "${(e)message:-You have new mail.}"
  27.     fi
  28. done
  29.