#!      /bin/csh -f
#
# Copyright 1993, 1994, 1995 by the Regents of the University of California.
# see the file "Copyright" in the distribution for conditions of use.
#
#
#       forward mail and send vacation notice
#
if( ! -e ~/.vacation.msg ) then
	echo 'First you need to create an automatic reply message.'
	exit 1
endif
#
retry:
echo ' '
echo -n 'Enter address to which you want mail forwarded, "q" to quit: '
set e = $<
set m = ( $e  )
if ( $#m == 0 ) then
	echo ' '
	echo 'No address entered; no change will be made'
	exit 0
else if ( $#m > 1 ) then
	echo ' '
	echo 'Address can not contain blanks.'
	goto retry
else if ( $m == "q" ) then
	exit 0
endif
#
#	======================================
#
set logon = $USER
if( ! -e ~${logon} ) then
	echo "*** can't figure out information - no changes made ***"
	exit 1
endif

#	set up .forward in temp
set new = `mktemp -c -pfrwrd`

cat << EOT >! $new
$e,
"|/usr/ccs/bin/vacation $logon"
EOT
#
#	initialize vacation
vacation -i

#	install .forward
install_forward $new
if ( $status ) then
	echo No changes made.
else
	echo Your mail will now be forwarded to \"$e\" and your vacation
	echo message will be sent to your correspondents.
endif
/bin/rm -f $new
exit 0
