#!/bin/csh -f # # cal3 by Curt McDowell # # Print out three calendars side by side: the previous month, # the current month, and the next month. It is also possible to # specify the month and/or year of the middle calendar. # set excode=1 if ( $#argv > 0 ) @ month=$1 # Strips leading zeroes if ( $#argv > 1 ) @ year=$2 if ( $#argv > 2 ) echo "Usage: cal3 [ month [ year ] ]" if ( $#argv > 2 ) exit 1 if ( ! $?year ) then set now=`date` set year=$now[6] if ( ! $?month ) then set month=`date +%m` endif endif if ( $year < 70 ) @ year += 2000 if ( $year < 100 ) @ year += 1900 if ( $month == 01 ) @ prevyear = $year - 1 if ( $month == 01 ) @ prevmonth = 12 if ( $month != 01 ) @ prevyear = $year if ( $month != 01 ) @ prevmonth = $month - 1 if ( $month == 12 ) @ nextyear = $year + 1 if ( $month == 12 ) @ nextmonth = 1 if ( $month != 12 ) @ nextyear = $year if ( $month != 12 ) @ nextmonth = $month + 1 set TMP1=/tmp/c3_a$$ set TMP2=/tmp/c3_b$$ set TMP3=/tmp/c3_c$$ if ( $month < 1 || $month > 12 ) then /bin/sh -c "echo 'cal3: Bad parameter.' 1>&2" goto end endif onintr end /usr/bin/cal $prevmonth $prevyear > $TMP1 /usr/bin/cal $month $year > $TMP2 /usr/bin/cal $nextmonth $nextyear > $TMP3 # /usr/ucb/head is required for some versions of pr (SunOS) /bin/pr -m -t $TMP1 $TMP2 $TMP3 | /usr/ucb/head -8 set excode=0 end: /bin/rm -f $TMP1 $TMP2 $TMP3 exit $excode