From 019895b9525b88638b046776c7708fe3bb8c1218 Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Sun, 27 Mar 1988 18:24:30 -0800 Subject: [PATCH] require '-' to run everybody's calendar; exit with correct status remove absolute path names SCCS-vsn: usr.bin/calendar/calendar.sh 4.7 --- usr/src/usr.bin/calendar/calendar.sh | 37 +++++++++++++++++++--------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/usr/src/usr.bin/calendar/calendar.sh b/usr/src/usr.bin/calendar/calendar.sh index ad106b4178..700cd6f1e9 100644 --- a/usr/src/usr.bin/calendar/calendar.sh +++ b/usr/src/usr.bin/calendar/calendar.sh @@ -1,16 +1,27 @@ -: calendar.sh 4.7 88/03/23 -PATH=/bin:/usr/bin:/usr/ucb +#!/bin/sh - +# +# Copyright (c) 1988 Regents of the University of California. +# All rights reserved. The Berkeley software License Agreement +# specifies the terms and conditions for redistribution. +# +# @(#)calendar.sh 4.7 (Berkeley) %G% +# +PATH=/usr/lib:/bin:/usr/bin:/usr/ucb:/lib # order important + tmp=/tmp/cal0$$ trap "rm -f $tmp /tmp/cal1$$ /tmp/cal2$$" trap exit 1 2 13 15 -/usr/lib/calendar >$tmp -case $# in -0) +calendar >$tmp + +if [ $# = 0 ]; then trap "rm -f $tmp ; exit" 0 1 2 13 15 - (/lib/cpp calendar | egrep -f $tmp);; -*) + (cpp calendar | egrep -f $tmp) + exit 0 +fi + +if [ $# = 1 ] && [ $1 = "-" ]; then trap "rm -f $tmp /tmp/cal1$$ /tmp/cal2$$; exit" 0 1 2 13 15 - /bin/echo -n "Subject: Calendar for " > /tmp/cal1$$ + echo -n "Subject: Calendar for " > /tmp/cal1$$ date | sed -e "s/ [0-9]*:.*//" >> /tmp/cal1$$ sed ' s/\([^:]*\):.*:\(.*\):[^:]*$/y=\2 z=\1/ @@ -20,11 +31,15 @@ case $# in eval $x if test -r $y/calendar then - (/lib/cpp $y/calendar | egrep -f $tmp) 2>/dev/null > /tmp/cal2$$ + (cpp $y/calendar | egrep -f $tmp) 2>/dev/null > /tmp/cal2$$ if test -s /tmp/cal2$$ then - cat /tmp/cal1$$ /tmp/cal2$$ | /bin/mail $z + cat /tmp/cal1$$ /tmp/cal2$$ | mail $z fi fi done -esac + exit 0 +fi + +echo "usage: calendar [-]" +exit 1 -- 2.20.1