#!	/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.
#
#
#	move/rename a file
#
echo -n 'Enter name of file to rename/move: '
set from = $<
set y = ( $from )
if ( $#y == 0 ) goto none_entered
if ( $#y > 1 ) then
	echo "*** Only one name allowed."
	exit
endif
if ( ! -e "$from" ) then
	echo "*** No such file"
	exit
endif
echo -n 'Enter new name of file: '
set to = $<
set y = ( $to )
if ( $#y == 0 ) goto none_entered
if ( $#y > 1 ) then
	echo "*** Only one name allowed."
	exit
endif
if ( -e "$to" ) then
	echo A file of that name already exists.
retry:
	echo -n "Do you want to overwrite it? (y/n) "
	set x = $<
	set y = ( $x )
	if( $#y != 1 ) set x = "ERR"
	if( $x == "n" ) exit
	if( $x != "y" ) then
		echo "***" You must enter "y" or "n".
		goto retry
	endif
endif
/bin/mv $from $to
exit

none_entered:
echo '*** No file name was entered.'
exit
