:
 #	UNIX floppy diskette copy program: @(#)fcopy.sh	1.8 87/11/19 
TMPFILE=/tmp/junk.DD$$ AGAIN=y NULL=/dev/null COMMAND=1
trap "rm -f $TMPFILE ; echo copy aborted ; trap 0; exit" 1 2 3 15
first=0
while :; do
if test "$COMMAND" -eq 3
	then exit 0
fi
echo "\n\nUNIX FLOPPY DISK COPY\n\n"
if test $first -ne 1
then echo -n "Choose:   1 - Copy low density floppy diskette
          2 - Copy high density floppy diskette
          3 - Quit\n\nCommand: "
	   read COMMAND;
else first=0
fi
	   case $COMMAND in
		  1) echo -n "\n Insert low density diskette, press RETURN ";
	             AGAIN=y;
		     read LINE;
		     dd if=/dev/rfd0 of=$TMPFILE bs=9b count=160 2>/dev/null | grep -v '+0 records ';
		     while expr $AGAIN : y > $NULL;
			do  
		           echo -n "
Insert blank low density diskette, press RETURN ";
			   read LINE;
		     	   dd if=$TMPFILE of=/dev/rfd0 bs=9b count=160 2>/dev/null | grep -v '+0 records '; 
			   YESORNO=false;
			   while test $YESORNO = false 
			   do
				   echo -n "
Do you want to make another copy of this diskette?  (y/n) "
				   read ANSWER
				   case $ANSWER in
	    			   yes | YES | Yes | [yY]) YESORNO=true;
		  		       AGAIN=y;;
	    			   no | NO | No | [nN]) YESORNO=true;
				       AGAIN=n;;
	    			   *)  YESORNO=false;
		  		       echo "Please answer \"yes\" or \"no\"";;
				   esac
			   done
		     done;;
		  2) echo -n "\n Insert high density diskette, press RETURN ";
	             AGAIN=y;
		     read LINE;
		     dd if=/dev/rfd0 of=$TMPFILE bs=15b count=160 2>/dev/null | grep -v '+0 records ';
		     while expr $AGAIN : y > $NULL;
			do  
		           echo -n "
Insert blank high density diskette, press RETURN ";
			   read LINE;
		     	   dd if=$TMPFILE of=/dev/rfd0 bs=15b count=160 2>/dev/null | grep -v '+0 records '; 
			   YESORNO=false;
			   while test $YESORNO = false 
			   do
				   echo -n "
Do you want to make another copy of this diskette?  (y/n) "
				   read ANSWER
				   case $ANSWER in
	    			   yes | YES | Yes | [yY]) YESORNO=true;
		  		       AGAIN=y;;
	    			   no | NO | No | [nN]) YESORNO=true;
				       AGAIN=n;;
	    			   *)  YESORNO=false;
		  		       echo "Please answer \"yes\" or \"no\"";;
				   esac
			   done
		     done;;
		3) echo "\nexiting floppy diskette copy program "
		   rm -r $TMPFILE >/dev/null  2>&1
		   exit;;
	esac;  
done
exit 
