BSD 4_3_Net_2 release
[unix-history] / usr / src / usr.bin / groff / grot / groff.sh
CommitLineData
0ac0e46a
C
1#!/bin/sh
2#Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
3# Written by James Clark (jjc@jclark.uucp)
4#
5#This file is part of groff.
6#
7#groff is free software; you can redistribute it and/or modify it under
8#the terms of the GNU General Public License as published by the Free
9#Software Foundation; either version 1, or (at your option) any later
10#version.
11#
12#groff is distributed in the hope that it will be useful, but WITHOUT ANY
13#WARRANTY; without even the implied warranty of MERCHANTABILITY or
14#FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15#for more details.
16#
17#You should have received a copy of the GNU General Public License along
18#with groff; see the file LICENSE. If not, write to the Free Software
19#Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21# Add new devices below, where it says `Add local devices here.'
22
23prog=`basename $0`
24optF=
25optP=
26optL=
27trflags=
28tflag=
29pflag=
30eflag=
31sflag=
32lflag=
33zflag=
34vflag=
35iflag=
36Cflag=
37Nflag=
38Vflag=
39dev=${GROFF_TYPESETTER:-@DEVICE@}
40
41synopsis="\
42usage: $prog [-abehilpstvzCENVZ] [-Hfile] [-Fdir] [-mname] [-Tdev] [-ffam]
43 [-wname] [-Wname] [ -Mdir] [-dcs] [-rcn] [-nnum] [-olist] [-Parg]
44 [-Larg] [files...]"
45
46devices="Available devices are:
47X100 X11 previewer at 100dpi
48X75 X11 previewer at 75dpi
49X100-12 X11 previewer at 100dpi (optimized for 12 point text)
50X75-12 X11 previewer at 75dpi (optimized for 12 point text)
51ps PostScript
52dvi TeX dvi format
53latin1 ISO Latin-1
54ascii ASCII"
55
56help="$synopsis
57-h print this message
58-t preprocess with tbl
59-p preprocess with pic
60-e preprocess with eqn
61-s preprocess with soelim
62-Tdev use device dev
63-mname read macros tmac.name
64-dcs define a string c as s
65-rcn define a number register c as n
66-nnum number first page n
67-olist output only pages in list
68-ffam use fam as the default font family
69-Fdir search directory dir for device directories
70-Mdir search dir for macro files
71-Hfile read hyphenation patterns from file
72-v print version number
73-z suppress formatted output
74-Z don't postprocess
75-a produce ASCII description of output
76-i read standard input after named input files
77-wname enable warning name
78-Wname inhibit warning name
79-E inhibit all errors
80-b print backtraces with errors or warnings
81-l spool the output (@PSPRINT@ or @DVIPRINT@)
82-C enable compatibility mode
83-V print the pipeline on stdout instead of executing it
84-Parg pass arg to the postprocessor
85-Larg pass arg to the spooler
86-N don't allow newlines within eqn delimiters
87
88$devices"
89
90usage="$synopsis
91$prog -h gives more help"
92
93while test $# -gt 0
94do
95 case $1 in
96 -h*)
97 echo "$help" >&2
98 exit 0
99 ;;
100 -[az])
101 trflags="$trflags $1"
102 zflag=1
103 ;;
104 -Z)
105 zflag=1
106 ;;
107 -i)
108 iflag=1
109 ;;
110 -V)
111 Vflag=1
112 ;;
113 -t)
114 tflag=1
115 ;;
116 -p)
117 pflag=1
118 ;;
119 -e)
120 eflag=1
121 ;;
122 -s)
123 sflag=1
124 ;;
125 -l)
126 lflag=1
127 ;;
128 -v)
129 vflag=-v
130 ;;
131 -C)
132 Cflag=-C
133 ;;
134 -N)
135 Nflag=-N
136 ;;
137 -[bE])
138 trflags="$trflags $1"
139 ;;
140 -[aiztpeslvbECNVZ]*)
141 first=`expr "$1" : '\(-.\)'`
142 rest=`expr "$1" : '-.\(.*\)$'`
143 shift
144 set "" "$first" "-$rest" "$@"
145 ;;
146 -F)
147 if test $# -lt 2
148 then
149 echo "$prog: option -F requires an argument" >&2
150 exit 1
151 else
152 optF="$optF -F$2"
153 shift
154 fi
155 ;;
156 -F*)
157 optF="$optF $1"
158 ;;
159 -T)
160 if test $# -lt 2
161 then
162 echo "$prog: option -T requires an argument" >&2
163 exit 1
164 else
165 dev="$2"
166 shift
167 fi
168 ;;
169
170 -T*)
171 dev=`expr "$1" : '-T\(.*\)$'`
172 ;;
173 -[fomrMHdnwW])
174 if test $# -lt 2
175 then
176 echo "$prog: option $1 requires an argument" >&2
177 exit 1
178 else
179 trflags="$trflags $1$2"
180 shift
181 fi
182 ;;
183 -[fomrMHdnwW]*)
184 trflags="$trflags $1"
185 ;;
186 -P)
187 if test $# -lt 2
188 then
189 echo "$prog: option -P requires an argument" >&2
190 exit 1
191 else
192 optP="$optP $2"
193 shift
194 fi
195 ;;
196 -P*)
197 optP="$optP `expr "$1" : '-.\(.*\)$'`"
198 ;;
199 -L)
200 if test $# -lt 2
201 then
202 echo "$prog: option -L requires an argument" >&2
203 exit 1
204 else
205 optL="$optL $2"
206 shift
207 fi
208 ;;
209 -L*)
210 optL="$optL `expr "$1" : '-.\(.*\)$'`"
211 ;;
212 --)
213 shift
214 break
215 ;;
216 -)
217 break
218 ;;
219 -*)
220 echo "$prog: unrecognized option $1" >&2
221 echo "$usage" >&2
222 exit 1
223 ;;
224 *)
225 break
226 ;;
227 esac
228 shift
229done
230
231if test $# -gt 0
232then
233 files="$@"
234 if test "$iflag"
235 then
236 files="$files -"
237 fi
238else
239 files=-
240fi
241
242eqnchar=
243eqnflag=
244picflag=
245postpro=
246
247case $dev in
248ps)
249 trflags="$trflags -mps"
250 eqnchar=@FONTDIR@/devps/eqnchar
251 postpro="| grops $vflag $optF $optP"
252 picflag="-x -p"
253 eqnflag=-D
254 if test "$lflag"
255 then
256 postpro="$postpro | @PSPRINT@ $optL"
257 fi
258 ;;
259
260X100|X75|X100-12|X75-12)
261 trflags="$trflags -mX"
262 picflag=-x
263 eqnflag=-D
264 postpro="| gxditview $optP -"
265 eqnchar=@FONTDIR@/dev$dev/eqnchar
266 ;;
267
268ascii|latin1)
269 trflags="$trflags -mtty"
270 postpro="| grotty $vflag $optF $optP"
271 ;;
272
273dvi)
274 trflags="$trflags -mdvi"
275 eqnchar=@FONTDIR@/devdvi/eqnchar
276 picflag=-x
277 postpro="| grodvi $vflag $optF $optP"
278 if test "$lflag"
279 then
280 postpro="$postpro | @DVIPRINT@ $optL"
281 fi
282 ;;
283
284
285# Add local devices here.
286
287*)
288 echo "$prog: unknown device \`$dev'" >&2
289 echo "$devices" >&2
290 exit 1
291 ;;
292esac
293
294prepro=
295
296if test "$sflag"
297then
298 prepro="$prepro gsoelim $vflag $Cflag $files |"
299 files=-
300fi
301
302if test "$pflag"
303then
304 prepro="$prepro gpic $vflag $Cflag $picflag $files |"
305 files=-
306fi
307
308if test "$tflag"
309then
310 prepro="$prepro gtbl $vflag $Cflag $files |"
311 files=-
312fi
313
314if test "$eflag"
315then
316 prepro="$prepro geqn $eqnflag $vflag $Cflag $Nflag -T$dev -- $eqnchar $files |"
317 files=-
318fi
319
320if test "$zflag"
321then
322 postpro=
323fi
324
325pipe="$prepro gtroff -T$dev $vflag $Cflag $trflags $optF -- $files $postpro"
326
327if test "$Vflag"
328then
329 echo $pipe
330else
331 eval $pipe
332fi
333exit 0