lp.sh revision 194171
11573Srgrimes#!/bin/sh 21573Srgrimes# 31573Srgrimes# 41573Srgrimes# Copyright (c) 1995 Joerg Wunsch 51573Srgrimes# 61573Srgrimes# All rights reserved. 71573Srgrimes# 81573Srgrimes# This program is free software. 91573Srgrimes# 101573Srgrimes# Redistribution and use in source and binary forms, with or without 111573Srgrimes# modification, are permitted provided that the following conditions 121573Srgrimes# are met: 131573Srgrimes# 1. Redistributions of source code must retain the above copyright 141573Srgrimes# notice, this list of conditions and the following disclaimer. 151573Srgrimes# 2. Redistributions in binary form must reproduce the above copyright 161573Srgrimes# notice, this list of conditions and the following disclaimer in the 171573Srgrimes# documentation and/or other materials provided with the distribution. 181573Srgrimes# 3. All advertising materials mentioning features or use of this software 191573Srgrimes# must display the following acknowledgement: 201573Srgrimes# This product includes software developed by Joerg Wunsch 211573Srgrimes# 4. The name of the developer may not be used to endorse or promote 221573Srgrimes# products derived from this software without specific prior written 231573Srgrimes# permission. 241573Srgrimes# 251573Srgrimes# THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 261573Srgrimes# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 271573Srgrimes# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 281573Srgrimes# IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 2950476Speter# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 301573Srgrimes# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31259872Spluknet# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 321573Srgrimes# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3379531Sru# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 341573Srgrimes# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35107913Sdillon# 36107913Sdillon# 3759460Sphantom# Posix 1003.2 compliant print spooler interface. 3859460Sphantom# 391573Srgrimes# $FreeBSD: head/usr.sbin/lpr/lp/lp.sh 194171 2009-06-14 06:47:21Z brian $ 4084306Sru# 411573Srgrimes 421573Srgrimesncopies="" 43107913Sdillonsymlink="-s" 44107913Sdillonmailafter="" 451573Srgrimestitle="" 46108028Sru 47108028Sru# Posix says LPDEST gets precedence over PRINTER 48108028Srudest=${LPDEST:-${PRINTER:-lp}} 4979754Sdd 501573Srgrimes# 511573Srgrimes# XXX We include the -o flag as a dummy. Posix 1003.2 does not require 52131504Sru# it, but the rationale mentions it as a possible future extension. 53131504Sru# XXX We include the -s flag as a dummy. SUSv2 requires it, 541573Srgrimes# although we do not yet emit the affected messages. 55131504Sru# 56131504Sruwhile getopts "cd:mn:o:st:" option 571573Srgrimesdo 581573Srgrimes case $option in 591573Srgrimes 60107913Sdillon c) # copy files before printing 61107913Sdillon symlink="";; 62107913Sdillon d) # destination 63107913Sdillon dest="${OPTARG}";; 64107913Sdillon m) # mail after job 65107913Sdillon mailafter="-m";; 661573Srgrimes n) # number of copies 671573Srgrimes ncopies="-#${OPTARG}";; 681573Srgrimes o) # (printer option) 691573Srgrimes : ;; 701573Srgrimes s) # (silent option) 71107913Sdillon : ;; 72107913Sdillon t) # title for banner page 73107913Sdillon title="-J${OPTARG}";; 74107913Sdillon *) # (error msg printed by getopts) 75107913Sdillon exit 2;; 7659954Sphantom esac 771573Srgrimesdone 781573Srgrimes 791573Srgrimesshift $(($OPTIND - 1)) 801573Srgrimes 811573Srgrimesexec /usr/bin/lpr "-P${dest}" ${symlink} ${ncopies} ${mailafter} "${title}" "$@" 821573Srgrimes