need param.h for mbuf.h now
[unix-history] / usr / src / usr.bin / calendar / calendar.sh
CommitLineData
019895b9
KB
1#!/bin/sh -
2#
3# Copyright (c) 1988 Regents of the University of California.
4# All rights reserved. The Berkeley software License Agreement
5# specifies the terms and conditions for redistribution.
6#
435e8dff 7# @(#)calendar.sh 4.8 (Berkeley) %G%
019895b9 8#
435e8dff 9PATH=/usr/libexec:/bin:/usr/bin:/usr/ucb:/lib:/usr/pgrm # order important
019895b9 10
aa6de038
RH
11tmp=/tmp/cal0$$
12trap "rm -f $tmp /tmp/cal1$$ /tmp/cal2$$"
492e9668 13trap exit 1 2 13 15
019895b9
KB
14calendar >$tmp
15
16if [ $# = 0 ]; then
f02f0c04 17 trap "rm -f $tmp ; exit" 0 1 2 13 15
019895b9
KB
18 (cpp calendar | egrep -f $tmp)
19 exit 0
20fi
21
22if [ $# = 1 ] && [ $1 = "-" ]; then
aa6de038 23 trap "rm -f $tmp /tmp/cal1$$ /tmp/cal2$$; exit" 0 1 2 13 15
019895b9 24 echo -n "Subject: Calendar for " > /tmp/cal1$$
aa6de038 25 date | sed -e "s/ [0-9]*:.*//" >> /tmp/cal1$$
04479c21
BJ
26 sed '
27 s/\([^:]*\):.*:\(.*\):[^:]*$/y=\2 z=\1/
28 ' /etc/passwd \
29 | while read x
30 do
31 eval $x
492e9668
BJ
32 if test -r $y/calendar
33 then
019895b9 34 (cpp $y/calendar | egrep -f $tmp) 2>/dev/null > /tmp/cal2$$
492e9668
BJ
35 if test -s /tmp/cal2$$
36 then
019895b9 37 cat /tmp/cal1$$ /tmp/cal2$$ | mail $z
492e9668 38 fi
04479c21
BJ
39 fi
40 done
019895b9
KB
41 exit 0
42fi
43
44echo "usage: calendar [-]"
45exit 1