#!	/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.
#
#
#	copy a file
#
echo -n 'Enter name of file to copy: '
set from = $<
set y = ( $from )
if( $#y == 0 ) goto none_entered
if( $#y != 1 ) then
	echo "*** Only one filename allowed."
	exit
endif
if( ! -e $from ) then
	echo "*** File does not exist."
	exit
endif
#
echo -n 'Enter name of copy: '
set to = $<
set y = ( $to )
if( $#y == 0 ) goto none_entered
if( $#y != 1 ) then
	echo "*** Only one filename 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/cp $from $to
exit

none_entered:
echo 'No file name was entered; no copy will be done.'
exit
