1#!/bin/sh 2# 3# 4# Copyright (c) 1995 Joerg Wunsch 5# 6# All rights reserved. 7# 8# This program is free software. 9# 10# Redistribution and use in source and binary forms, with or without 11# modification, are permitted provided that the following conditions 12# are met: 13# 1. Redistributions of source code must retain the above copyright 14# notice, this list of conditions and the following disclaimer. 15# 2. Redistributions in binary form must reproduce the above copyright 16# notice, this list of conditions and the following disclaimer in the 17# documentation and/or other materials provided with the distribution. 18# 3. All advertising materials mentioning features or use of this software 19# must display the following acknowledgement: 20# This product includes software developed by Joerg Wunsch 21# 4. The name of the developer may not be used to endorse or promote 22# products derived from this software without specific prior written 23# permission. 24# 25# THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 26# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 27# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 28# IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 29# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 30# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35# 36# 37# Posix 1003.2 compliant print spooler interface. 38# 39# $Id: lp.sh,v 1.1 1995/01/22 17:47:33 j Exp $ 40# 41# 42# XXX Bugs: 43# . Our lpr command is not smart enough about dashes as input file names, 44# they should indicate the use of standard input. 45# . Our /bin/sh is not Posix-1003.2 compliant in its getopts command; 46# if the user specifies an option argument immediately after the 47# option, the variable OPTIND will be set wrong. (This way of 48# specifying option arguments is deprecated by Posix, but explicitly 49# allowed.) 50# . Our lpr command should allow the Posix-compliant way of specifying 51# options that take an argument; it currently requires the argument 52# to follow the option immediately. 53 54ncopies="" 55symlink="-s" 56 57# Posix says LPDEST gets precedence over PRINTER 58dest=${LPDEST:-${PRINTER:-lp}} 59 60# 61# XXX We include the -o flag as a dummy. Posix 1003.2 does not require 62# it, but the rationale mentions it as a possible future extension. 63# 64while getopts "cd:n:o:" option 65do 66 case $option in 67 68 c) # copy files before printing 69 symlink="";; 70 d) # destination 71 dest="${OPTARG}";; 72 n) # number of copies 73 ncopies="-#${OPTARG}";; 74 o) # (printer option) 75 : ;; 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} "$@" 84