1#!/bin/sh
2#
3#	$NetBSD: lp,v 1.4 1998/07/07 17:05:28 mrg Exp $
4#
5# Copyright (c) 1995 Joerg Wunsch
6#
7# All rights reserved.
8#
9# This program is free software.
10#
11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions
13# are met:
14# 1. Redistributions of source code must retain the above copyright
15#    notice, this list of conditions and the following disclaimer.
16# 2. Redistributions in binary form must reproduce the above copyright
17#    notice, this list of conditions and the following disclaimer in the
18#    documentation and/or other materials provided with the distribution.
19# 3. All advertising materials mentioning features or use of this software
20#    must display the following acknowledgement:
21#	This product includes software developed by Joerg Wunsch
22# 4. The name of the developer may not be used to endorse or promote
23#    products derived from this software without specific prior written
24#    permission.
25#
26# THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
27# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29# IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
30# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36#
37#
38# Posix 1003.2 compliant print spooler interface.
39#
40# from: Id: lp.sh,v 1.5 1997/02/22 16:06:14 peter Exp
41#
42
43ncopies=""
44symlink="-s"
45reqid="-R"
46
47# Posix says LPDEST gets precedence over PRINTER
48dest=${LPDEST:-${PRINTER:-lp}}
49
50#
51# XXX We include the -o flag as a dummy.  Posix 1003.2 does not require
52# it, but the rationale mentions it as a possible future extension.
53#
54while getopts "cd:n:o:s" option
55do
56	case $option in
57
58	c)			# copy files before printing
59		symlink="";;
60	s)			# silent
61		reqid="";;
62	d)			# destination
63		dest="${OPTARG}";;
64	n)			# number of copies
65		ncopies="-#${OPTARG}";;
66	o)			# (printer option)
67		: ;;
68	*)			# (error msg printed by getopts)
69		exit 2;;
70	esac
71done
72
73shift $(($OPTIND - 1))
74
75exec /usr/bin/lpr "-P${dest}" ${reqid} ${symlink} ${ncopies} "$@"
76