#! /bin/sh -e
#Tag 1538
# $Id: to_dos 10704 2007-05-10 17:27:40Z  $
#
# 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 [ $# -gt 2 ]
then
	echo "usage: to_dos [<unix_file> [<dos_file>]]"
	exit 1
fi


if [ $# -gt 0 ]
then
	nawk '{printf("%s\r\n", $0);}' "$1" > $TMPFILE
else
	nawk '{printf("%s\r\n", $0);}' > $TMPFILE
fi

# Stick on the EOF character
echo '\c' >> $TMPFILE

if [ $# -eq 2 ]
then
	mv -f $TMPFILE "$2"
else
	cat $TMPFILE
	rm $TMPFILE
fi
