#! /bin/sh

# LPH - print files with bannered filenames.
#	options:
#		-L	Add line numbers
#	All other options are passed to lpl.

notfirst=false lpargs=-h tmp=/tmp/lph$$
cat="sed 's/^/	/'"

/bin/rm -f $tmp
for a
do
	case "$a" in
	-L)	cat="cat -n";;
	-*)	lpargs="$lpargs $a";;
	*)	if test -r "$a"
		then
			if $notfirst
			then	echo -n '' >> $tmp
			else	notfirst=true
			fi
			{
			banner -u@ "`basename "$a" | tr a-z A-Z`"
			echo -n "$a printed for $USER from `hostname` on "
			date
			echo
			eval "$cat" '"$a"'
			} >> $tmp
		else
			echo lph: Cannot open $a 1>&2
		fi;;
	esac
done
lpl $lpargs $tmp && rm -f $tmp
