#
#####Message Texts######
set mesg1 = "Please enter the name of the group to be deleted:"
set mesg2a = "Group "
set mesg2b = " not found, please check and try again."
set mesg3a = "Delete "
set mesg3b = " from group file(yes or no):"
set mesg4a = "There are users who depend on "
set mesg4b = " as their primary group;"
set mesg5 = "do you still wish to delete this group(yes or no):"
########################
cp getinfo getinfo.sav	
						# find out which group to kill
echo -n $mesg1' '
scanname:
set name = ($<)
if ($#name == 0) then
	goto scanname
endif
						# make sure this user exists
awk '{FS=":"} {print $1}' /etc/group > foo 
fgrep -s $name foo
if ($status == 1) then
	echo -n $mesg2a $name $mesg2b' '
	goto scanname
endif
						# ask for verification
echo -n $mesg3a $name $mesg3b' '
set verify =($<)
if (($verify == n) | ($verify == no)) then
	exit(0)					#if verification neg., quit here
endif
				# determine if users depend upon this group
sed s/xx/$name/g getinfo > temp
sed s/\$\6/\$\3/ temp > getinfo
awk -f getinfo /etc/group > hold
mv getinfo.sav getinfo		# restore getinfo

awk '{FS=":"} {print $4}' /etc/group > foo 
fgrep -s `cat hold` foo
if ($status != 1) then
	echo $mesg4a $name $mesg4b
	echo -n $mesg5' '
	set continue = ($<)
	if (($continue == n) | ($continue == no)) then
		exit(0)
	endif
endif


/bin/rm hold
/bin/rm foo
exit(0)
