Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Recreated sources for the book “UNIX Text Processing,” published in 1987 (github.com/larrykollar)
138 points by rdpintqogeogsaa on Feb 19, 2022 | hide | past | favorite | 22 comments


The archive.org [1] page has a preformatted version and more info.

[1]: https://archive.org/details/utp_book/page/n3/mode/2up


Thanks. Link for the complete PDF book, from that page: https://archive.org/download/utp_book/utp_book.pdf


Just had to try running this on Slackware 15 with the groff that is part of the install. The git source has a hardwired path to ghostscript/9.53.3/..some font. Just symlinked to the 9.55.0 present in Slackware and there we are, a pdf file, with some warnings about bookmarks and a table with zero width spacing. Impressive work.

Thanks to those responsible for this both for the book and for an example of how to produce a book with groff using the ms macros.


I kept my resume in troff from maybe late 80s until early 2017. troff is really weird, a genuinely different kind of text formatting. The fact that something as commonplace as text formatting can have such divergent methods as troff, lout and TeX has kept me looking for things like different pattern matching, something not at all like regular expressions.


There’s lex (https://en.wikipedia.org/wiki/Lex_(software)) and parser generators such as yacc (https://en.wikipedia.org/wiki/Yacc).

And what do you find weird in troff? I see it as an early markdown, or rather, markdown as yet another take on runoff (https://en.wikipedia.org/wiki/TYPSET_and_RUNOFF). Markdown is a bit more implicit and (unless you ‘escape’ out of it using html) has fewer features, but I don’t see it as that different.


I'm aware of the Chomsky hierarchy. You can express more in a language with a grammar than one described by regular expressions.

What's weird in troff: macros aren't particularly easy. Also the necessity of mixing "semantic" macros (.PP or whatever for "here's a paragraph") with fine-grained typesetting directives. There's also some property of .troff that although the language is enough to write old school file viruses (here's something about a TeX virus: https://www.usenix.org/system/files/login/articles/73506-che..., can't find the troff virus citation), I don't think anyone has ever been able to write a troff self-replicating program. It appears you can't write a macro that puts a '.' at the beginning of the line or something like that.

I'm also aware that Stevens typeset all of this books with troff. It's very capable and unlike some other word processing systems, you can keep troff files in version control systems meaningfully.


> can't find the troff virus citation

Reading http://www.di-srv.unisa.it/~ads/corso-security/www/HTML/VIRU... using my very rudimentary understanding of Italian, I think that would be

P. Beyls, “Is Unix resistant to computer viruses?” Proceedings of the European UNIX systems UserGroup, pp 229-238, Münich, Germany, April 23-27 1990

I can’t find that online.

Amazon knows of the 1988 and 1989 proceedings, but not of those for 1990, and neither of those is available (https://www.amazon.com/s?i=stripbooks&rh=p_27%3AEuropean+UNI...)


I tried that and every recruiter wanted a word doc anyway. Didn't matter how beautiful the resume was in *roff or TeX; they couldn't quickly remove your info and put theirs at the top if you only sent them hardcopy or a PDF, so they didn't want it.


Pretty much same here for a while. The last 5 years I've been able to get away with a LaTeX resume, and give out PDFs.


You could look at an XML publishing pipeline (XML + XSLT + XML-FO).


Previous discussion about this book (2012): https://news.ycombinator.com/item?id=4902595


Most people assume UNIX typesetting was always just TeX - but troff and friends was probably more widespread at the time.


The book I learned writing networking code from, Steven's "Unix Network Programming" (https://en.wikipedia.org/wiki/UNIX_Network_Programming) was typeset in troff. The first edition (1990) at least. The later ones aren't I think. Stevens passed away in 1999. I recall coming across many other books which mentioned "troff" in the introduction back then.


"The Unix Programming Environment" & "The C programming language" (K & R) were also written in troff.


Hard to believe it’s been that long since he passed. Was quite the blow.

I was pleasantly surprised to find he wrote a Forth primer for Kitt Peak observatory. Linked from this page: http://www.forth.org/tutorials.html


IIRC UNIX was supported by Bell Labs because of troff. They needed a type setting system.


Thought that was more how they convinced management to buy PDP11 saying we'll make typesetting software for patent department?


This is great. I've long had a paper copy on my bookshelf.

I did notice when building this on OSX changing the makefile to call env to get groff and awk is required to work with homebrew.

I did submit an issue on the github about this however.


/usr/bin/groff -Tpdf -P-pletter -step -ms -z -rpdf:bm.nr=1 -rRef=0 -dPDF.EXPORT=1 utp_book.t 2>&1 | grep '^.ds' | /usr/bin/groff -Tpdf -P-pletter -step -ms -rRef=0 - utp_book.t >utp_book.pdf.tmp /usr/bin/groff: can't find `DESC' file /usr/bin/groff:fatal error: invalid device `pdf' make: ** [utp_book.pdf] Error 3

Just replace -Tpdf by -Tps in Makefile and run ps2pdf manually afterwards, then it works.


Notes from W. Richard Stevens on the subject @ http://www.kohala.com/start/#typesetting


Related: "Unix™ NROFF/TROFF A User's Guide" by Kevin P. Roddy got me through all my troff-related work back in the day.


I actually have that book :) I thought it was very informative.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: