xref: /freebsd/usr.sbin/lpr/lp/lp.sh (revision ebacd8013fe5f7fdf9f6a5b286f6680dd2891036)
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# $FreeBSD$
42#
43
44ncopies=""
45symlink="-s"
46mailafter=""
47title=""
48
49# Posix says LPDEST gets precedence over PRINTER
50dest=${LPDEST:-${PRINTER:-lp}}
51
52#
53# XXX We include the -o flag as a dummy.  Posix 1003.2 does not require
54# it, but the rationale mentions it as a possible future extension.
55# XXX We include the -s flag as a dummy.  SUSv2 requires it,
56# although we do not yet emit the affected messages.
57#
58while getopts "cd:mn:o:st:" option
59do
60	case $option in
61
62	c)			# copy files before printing
63		symlink="";;
64	d)			# destination
65		dest="${OPTARG}";;
66	m)			# mail after job
67		mailafter="-m";;
68	n)			# number of copies
69		ncopies="-#${OPTARG}";;
70	o)			# (printer option)
71		: ;;
72	s)			# (silent option)
73		: ;;
74	t)			# title for banner page
75		title="${OPTARG}";;
76	*)			# (error msg printed by getopts)
77		exit 2;;
78	esac
79done
80
81shift $(($OPTIND - 1))
82
83exec /usr/bin/lpr "-P${dest}" ${symlink} ${ncopies} ${mailafter} ${title:+-J"${title}"} "$@"
84