#! /bin/sh -e
#
# convert a UNIX ASCII file to a DOS ASCII file by appending ^M at the
# end of each line and ^Z at the end of the file

TMPFILE=/tmp/to_dos$$

if [ $# != 2 ]
then
	echo "usage: to_dos <unix_file> <dos_file>"
	exit 1
fi

sed -e 's/$/
/' "$1" > $TMPFILE

#  If the file does not end in a newline, get the last partial line.
#  (Yes, this is ugly.)

case `tail -1c "$1" | wc -l` in
    *0) tail -0 "$1" >> $TMPFILE;;
esac

echo '\c' >> $TMPFILE
mv -f $TMPFILE "$2"
