#!	/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.
#
#
#	select a real name for use in the menu system
#
#	find out what the person's name is ...
set menu_name = ( $NAME )
#
#
cat << EOT

When a program wants to display your name, the default is to
use your full name as supplied by the Office of Admissions
and Records or the Payroll Office.

Places this occurs include:

	- the Pine and BSD mailers (inserting your name in mail headers)

	- the Usenet news programs (inserting your name in article headers)

	- "finger" output

This menu entry allows you to change how your name appears in mail
sent by Pine and BSD mail and in articles you post.  It does not alter
your identity as reported by "finger".

Your name currently appears as:

	$menu_name

EOT
retry1:
echo -n 'Do you want to specify a different name? (y/n): '
set x = $<
set y = ( $x )
if( $#y == 0 || $#y > 1 ) set x = "ERR"
if( $x == "no" || $x == "n" ) exit
if( $x != "yes" && $x != "y" ) then
	echo 'You must specify "y" or "n".'
	echo ' '
	goto retry1
endif

#	wants a different name

echo ' '
echo -n "Ok. Enter what you want for your name: "
set menu_name = $<
set y = ( $menu_name )
if( $#y == 0 ) then
	echo "*** Nothing entered, name will not be changed."
	exit
endif

#	got name - change it

set_env_var NAME "$menu_name"
if( $status ) exit 1

cat << "EOT"

Ok, your name is now updated for the Usenet news system
and BSD mail systems.

"EOT"

#	now for .pinerc
if( -e ~/.pinerc ) goto got_pinerc
cat << "EOT"

Evidently you have not yet used Pine.  Your name can not be updated
for Pine messages until after you have used Pine.  Try again then.

"EOT"

got_pinerc:

set tempt = `mktemp -c`
set tempp = `mktemp -c -p.tmp -d ~`
sed -e "s/^personal-name=.*/personal-name=$menu_name/" < ~/.pinerc > $tempt
/bin/cp $tempt $tempp
cmp -s $tempt $tempp
if( $status ) goto quota_err
/bin/mv $tempp ~/.pinerc

cat << "EOT"
Ok, your name is now updated for Pine.

"EOT"
exit 0


quota_err:
cat << "EOT"

The requested operation failed, probably due to quota errors.

"EOT"
