[net.bugs.4bsd] Mods to 4.2BSD calendar facility

dan@rna.UUCP (05/10/84)

Hi,
	Here are some minor mods to the 4.2BSD (and V7) calendar facility.
The big change is that the shell script /usr/bin/calendar scans a user's
mail file and only mails him the calendar items that he doesn't yet have
mail for.
	Minor changes include accepting $HOME/Calendar as well as
$HOME/calendar, giving you two days notice instead of just one, including
a public calendar and always reminding you of items flagged with a '*'
in place of a date.
	These mods make the calendar facility seem a little more useable.

					Cheers,
					Dan Ts'o
					...cmcl2!rna!dan	

*** /usr/bin/calendar
#!/bin/sh
: calendar.sh 4.4 82/11/07
: Mods by Dan Tso@rna

PATH=/bin:/usr/bin:
tmp=/tmp/cal$$
tmp1=/tmp/cal$$.
tmp2=/tmp/cal$$..
tmp3=/tmp/cal$$...
mailpath=/usr/spool/mail
pubcal=/usr/pub/calendar
trap "rm -f $tmp $tmp1 $tmp2 $tmp3; exit" 0 1 2 13 15

/usr/lib/calendar >$tmp
/lib/cpp $pubcal | egrep -f $tmp 2>/dev/null > $tmp3

case $# in
0)
	cat [cC]alendar | /lib/cpp | egrep -f $tmp
	cat $tmp3
	;;
*)
	sed 's/\([^:]*\):.*:\(.*\):[^:]*$/y=\2 z=\1/' /etc/passwd \
	| while read x
	do
		eval $x
		if [ -r $y/calendar -o -r $y/Calendar ]
		then
			(cat $y/[Cc]alendar | /lib/cpp | egrep -f $tmp) 2>/dev/null > $tmp1
			cat $tmp3 >> $tmp1
			if [ -s $tmp1 ]
			then
				if [ -s $mailpath/$z ]
				then
					sort $tmp1 > $tmp2
					sort $mailpath/$z | comm -23 $tmp2 - > $tmp1
				fi
				if [ -s $tmp1 ]
				then
					mail $z < $tmp1
				fi
			fi
		fi
	done
	;;
esac
***************
*** calendar.c	Tue Feb 21 17:09:29 1984
--- calendar.c.org	Tue Feb 21 16:56:15 1984
***************
*** 52,62
  	default:
  		t += DAY;
  		tprint(t);
- 		/*
- 		* ADD ANOTHER DAY
- 		*/
- 		t += DAY;
- 		tprint(t);
  	}
  	/*
  	 * Added feature: Lines starting with * are always printed.

--- 52,56 -----
  	default:
  		t += DAY;
  		tprint(t);
  	}
  }
***************
*** 58,67
  		t += DAY;
  		tprint(t);
  	}
- 	/*
- 	 * Added feature: Lines starting with * are always printed.
- 	 * (constant reminder)
- 	 */
- 	printf("(^\\*)\n");
- 	exit(0);
  }

--- 53,56 -----
  		t += DAY;
  		tprint(t);
  	}
  }