#!/bin/sh # agenda--Scans through the user's .agenda file to see if there # are matches for the current or next day. setglobal agendafile = ""$HOME/.agenda"" proc checkDate { # Create the possible default values that'll match today. setglobal weekday = $1, day = $2, month = $3, year = $4 setglobal format1 = $weekday, format2 = ""$day$month"," format3 = ""$day$month$year"" # And step through the file comparing dates... setglobal IFS = '"|'" # The reads will naturally split at the IFS. echo "On the agenda for today:" while read date description { if test $date = $format1 -o $date = $format2 -o \ $date = $format3 { echo " $description" } } < $agendafile } if test ! -e $agendafile { echo "$0: You don't seem to have an .agenda file. " > !2 echo "To remedy this, please use 'addagenda' to add events" > !2 exit 1 } # Now let's get today's date... eval $[date '+weekday="%a" month="%b" day="%e" year="%G"] setglobal day = $[echo $day|sed 's/ //g] # Remove possible leading space. checkDate $weekday $day $month $year exit 0