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