BSD 4_1_snap release
[unix-history] / usr / src / cmd / calendar / calendar.sh
old mode 100755 (executable)
new mode 100644 (file)
index 606a6cb..ab0f592
@@ -1,19 +1,28 @@
-PATH=/bin:/usr/bin
+: calendar.sh 4.3 82/02/13
+PATH=/bin:/usr/bin:
 tmp=/tmp/cal$$
 tmp=/tmp/cal$$
-trap "rm $tmp; exit" 0 1 2 13 15
+trap "rm -f $tmp /tmp/cal2$$"
+trap exit 1 2 13 15
 /usr/lib/calendar >$tmp
 case $# in
 0)
 /usr/lib/calendar >$tmp
 case $# in
 0)
+       trap "rm -f $tmp ; exit" 0 1 2 13 15
        egrep -f $tmp calendar;;
 *)
        egrep -f $tmp calendar;;
 *)
+       trap "rm -f $tmp /tmp/cal2$$; exit" 0 1 2 13 15
        sed '
                s/\([^:]*\):.*:\(.*\):[^:]*$/y=\2 z=\1/
        ' /etc/passwd \
        | while read x
        do
                eval $x
        sed '
                s/\([^:]*\):.*:\(.*\):[^:]*$/y=\2 z=\1/
        ' /etc/passwd \
        | while read x
        do
                eval $x
-               if test -r $y/calendar; then
-                       egrep -f $tmp $y/calendar 2>/dev/null  | mail $z
+               if test -r $y/calendar
+               then
+                       egrep -f $tmp $y/calendar 2>/dev/null  > /tmp/cal2$$
+                       if test -s /tmp/cal2$$
+                       then
+                               < /tmp/cal2$$ mail $z
+                       fi
                fi
        done
 esac
                fi
        done
 esac