Neat little alias & technique to facilite troff

Gary Puckering garyp at cognos.UUCP
Thu Jan 22 01:46:16 AEST 1987


In article <920 at houxu.UUCP> jhv at houxu.UUCP writes:
>My approach is to use the shell's "here-document" capability, putting the
>command line  to format the document as the first line of the document, and
>executing the file when I need processed output, for example (to include
>tbl, eqn, and pic preprocessors and to print the output on an Imagen
>printer):
>	tbl <<!EOF | eqn | pic | troff -mm | ipr -ltroff
>	...
>	!EOF
>Then either make the file executable with chmod, or type sh filename to get
>the formatted output.

Neat idea.  I like it.  One problem though -- how do you allow for both
printed output and terminal output.  So, I fiddled for awhile and got
this to work:

     if test "$1" = -p 
     then
     	roff="ptroff -ms"
     else
     	roff="nroff -ms | more"
     fi
     echo $roff
     eval $roff <<!EOF
     ...
     !EOF

Run this through sh and it will nroff to the terminal.  Add the -p
parameter and it will ptroff to the printer.
-- 
Gary Puckering        3755 Riverside Dr.
Cognos Incorporated   Ottawa, Ontario
(613) 738-1440        CANADA  K1G 3N3



More information about the Comp.sources.bugs mailing list