#**********************************************************************#
#*                                                                    *#
#* Copyright (c) 2001 by Sun Microsystems, Inc.                       *#
#* All rights reserved.                                               *#
#*                                                                    *#
#**********************************************************************#

: $Workfile:   SPOOLER.sh  $ $Revision:   1.1  $
# Spooler to HOME directory

FILE=
PRINTER=

SPOOLDIR=$HOME/spool
if test ! -d $SPOOLDIR
then
    mkdir $SPOOLDIR
    if test $? -ne 0
    then
	SPOOLDIR=$HOME
	# should exist and be writable
    fi
fi

SPOOLFILE=$SPOOLDIR/print.$$

while test -n "$1"
do
    case "$1" in
    -p)
	PRINTER=$2
	shift
	;;
    -p*)
	PRINTER=$1
	;;
    *)
	FILE="$FILE $1"
	;;
    esac
    shift
done

# if no file given, assume stdin
if test -z "$FILE"
then
    FILE="-"
fi

if test -n "$PRINTER"
then
    ( echo "PRINTER $PRINTER" ; cat $FILE ) >>$SPOOLFILE
else
    cat $FILE >>$SPOOLFILE
fi

