#!/bin/sh
#
#	Output or print PostScript file of programming card
#
#	Written by Jonathan Bowen, March 1988.
#	Minor updates, September 1988.
#

PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/news/bin
PROGNAME=`basename $0`
TMP=/tmp/$PROGNAME$$
# SEP='                       '
# SEP='            '
#    123456789012345678901234567890
SEP='                '
PRINT=false

case $1 in
"")
	echo "Usage: $PROGNAME [-p] file ..."
	exit 0
	;;
-|-p|-P) : print output
	PRINT=true
	shift
	;;
esac

# Concatenate the input files
for FILE in $*
do
{
	if [ -r $FILE -a ! -d $FILE ]
	then
		cat $FILE
	elif [ -r $FILE.Z -a ! -d $FILE.Z ]
	then
		zcat $FILE
	else
		echo "$PROGNAME: Can't read $FILE" 2>&1
	fi |
# Make into three columns (-g16)
	rs -et -g16 -w240 80 3
}
done |

# Remove blank lines
sed '/^ *$/d' |

# Add leading spaces
sed "s/^/$SEP/" |

# Convert to PostScript
enscript -rB -L80 -fCourier5 -p- |

# Optionally print output
if $PRINT
then
	lpr -Pps -J"$*"
else
	cat
fi

exit 0

