source: trunk/packs/glue/os/linux/lp.sh @ 17989

Revision 17989, 2.7 KB checked in by zacheiss, 22 years ago (diff)
lp compatability script and Makefile rules to install it.
Line 
1#!/bin/sh
2# $Id: lp.sh,v 1.1 2002-10-22 20:14:15 zacheiss Exp $
3
4# This script emulates the System V lp command using the Athena lpr
5# command.  The emulation is not perfect; the known imperfections are:
6#
7#       * The -s option is ignored, since lpr doesn't normally print
8#         output and doesn't have an option to suppress it when it
9#         does.
10#
11#       * The -m and -w options, which cause mail to be sent or a
12#         message to be written to the user when the print job is
13#         done, are both replaced with -z, which causes a zephyr to be
14#         sent to the user when the print job is done.
15#
16#       * All -o options are ignored (normally they are
17#         printer-specific options) except for "nobanner".
18#
19#       * Arguments to some options may be expanded twice for words and
20#         globbing.
21
22lpr=/usr/athena/bin/lpr
23
24# Parse command-line flags.
25opts=""
26suppress_s=no
27content=""
28pages=""
29title=""
30usage="lp [-P pagerange] [-T content-type] [-c] [-d dest] [-m] [-n number]
31   [-o option] [-t title] [-w] [file ...]"
32while getopts H:P:S:T:cd:fmn:o:pq:rst:wy: opt; do
33        case "$opt" in
34        H)
35                echo "lp: Spooling system does not support special handling." \
36                        1>&2
37                ;;
38        P)
39                pages="$OPTARG"
40                ;;
41        S)
42                echo "lp: Spooling system does not support print wheels." 1>&2
43                ;;
44        T)
45                content="$OPTARG"
46                ;;
47        c)
48                suppress_s=yes
49                ;;
50        d)
51                opts="$opts -P $OPTARG"
52                ;;
53        f)
54                echo "lp: Spooling system does not support forms." 1>&2
55                exit 1
56                ;;
57        m)
58                opts="$opts -z"
59                ;;
60        n)
61                opts="$opts -#$OPTARG"
62                ;;
63        o)
64                case "$OPTARG" in
65                nobanner|*,nobanner|nobanner,*|*,nobanner,*)
66                        opts="$opts -h"
67                        ;;
68                esac
69                ;;
70        p|q|r|s)
71                ;;
72        t)
73                title="$OPTARG"
74                ;;
75        w)
76                opts="$opts -z"
77                ;;
78        y)
79                echo "lp: Spooling system does not support mode list." 1>&2
80                ;;
81        \?)
82                echo "$usage" 1>&2
83                exit 1
84                ;;
85        esac
86done
87if [ "$suppress_s" = no ]; then
88        opts="$opts -s"
89fi
90
91# Find filter to use for content type, if any.
92filter=""
93case ${content:-simple} in
94simple|postscript)
95        ;;
96*)
97        echo "lp: Spooling system does not support content-type" \
98                " $content" 1>&2
99        ;;
100esac
101
102# If a page range was specified, see if the filter supports it, and
103# switch to using a filter if the content type is simple or
104# postscript.  Page ranges won't work if no content type is specified,
105# since we don't know if files are text or postscript and there's no
106# filter which does automatic recognition.
107case "$pages" in
108"")
109        ;;
110*)
111        echo "lp: Spooling system does not support page ranges." 1>&2
112        exit
113        ;;
114esac
115
116shift `expr $OPTIND - 1`
117
118if [ -n "$filter" ]; then
119        # This option may not work with all lpr options.
120        if [ -z "$title" -a $# -eq 0 ]; then
121                title="(stdin)"
122        fi
123        for file in "${@:--}"; do
124                $filter $file | $lpr -J "${title:-$file}" $opts
125        done
126else
127        if [ -z "$title" ]; then
128                title="${@:-(stdin)}"
129        fi
130        exec $lpr -J "$title" $opts "$@"
131fi
Note: See TracBrowser for help on using the repository browser.