xref: /netbsd/usr.sbin/lpr/lp/lp (revision bf9ec67e)
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"
45
46# Posix says LPDEST gets precedence over PRINTER
47dest=${LPDEST:-${PRINTER:-lp}}
48
49#
50# XXX We include the -o flag as a dummy.  Posix 1003.2 does not require
51# it, but the rationale mentions it as a possible future extension.
52#
53while getopts "cd:n:o:s" option
54do
55	case $option in
56
57	c)			# copy files before printing
58		symlink="";;
59	s)			# silent
60		: ;;
61	d)			# destination
62		dest="${OPTARG}";;
63	n)			# number of copies
64		ncopies="-#${OPTARG}";;
65	o)			# (printer option)
66		: ;;
67	*)			# (error msg printed by getopts)
68		exit 2;;
69	esac
70done
71
72shift $(($OPTIND - 1))
73
74exec /usr/bin/lpr "-P${dest}" ${symlink} ${ncopies} "$@"
75