#! /bin/csh
#
# Name:
#	 UNRHOST
#
# syntax:
#
#	 UNRHOST file [file ...]
#
# Description:
#
#	for each file:
#		mv .file. file
#		rm .file.$RHOST
#
#
set i = ($*)
if ($#i == 0) then
# 
# NB: order is important: one has to have <foo> before <foo>.x in the following
#
	set i = ( /etc/utmp /usr/adm /usr/lib/crontab /etc/ttys /etc/ttytype /tmp /usr/tmp /etc/rc.local /etc/rc /usr/spool/rwho)

endif
foreach f ($i)
	set head = $f:h
	set tail = $f:t
	if ( $head == $tail ) then
		set hidden = .${head}.
	else
		set hidden = ${head}/.${tail}.
	endif
	echo $hidden
	if ( ! -e $hidden ) then
		echo $hidden not found
	else

#
# change original name back (.foo. to foo) and remove the
# symbolic link (.foo.$RHOST).
#
		if ( -e $hidden ) then
			if ( -e $f ) then
				rm -rf $f
			endif
			mv $hidden $f
			if ( -e ${hidden}'$RHOST' ) \
				rm -rf ${hidden}'$RHOST'
			foreach f (${HIDDEN}*)
				rm -rf ${hidden}*
			end
		endif
	endif
end
