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