#!/bin/rc # By tweedy. Version of 12 Jun 2022. # Informs you of any new mail. # -l list of new messages # -a list of all messages # -h this help message switch($1){ case -a* m=`{ls /mail/box/$user/mbox} if(test $m(1)){ newmail=false cd /mail/fs/mbox for(i in *){ if(~ $i [1-9]*){ unread=`{awk '{print substr($0,6,1)}' $i/flags} subj=`{cat $i/subject} if(~ $subj '') subj='(no subject)' echo '*' `{cat $i/from} : $subj } } } if not echo No mail case -l* m=`{ls /mail/box/$user/mbox} if(test $m(1)){ newmail=false cd /mail/fs/mbox for(i in *){ if(~ $i [1-9]*){ unread=`{awk '{print substr($0,6,1)}' $i/flags} subj=`{cat $i/subject} if(~ $subj '') subj='(no subject)' if(~ $unread -) { echo '*' `{cat $i/from} : $subj newmail=true } } } if(~ $newmail false) echo No new mail } if not echo No mail case '' m=`{ls /mail/box/$user/mbox} if(test $m(1)){ newmail=false cd /mail/fs/mbox for(i in *){ if(~ $i ctl) dummy=() if not{ unread=`{awk '{print substr($0,6,1)}' $i/flags} if(~ $unread -) newmail=true } } if(~ $newmail true) echo You have new mail if not echo No new mail } if not echo No mail case * echo Informs you of any new mail. echo -l list of new messages echo -a list of all mail messages echo -h this help message }