Nixers Book Club - Book #1: The UNIX Programming Environment - Community & Forums Related Discussions

Users browsing this thread: 1 Guest(s)
Chapter 9 - Document Preparation

This chapter focuses on document editing and formatting, it is a bit special because this was UNIX first application — it was the word editor of the time.
In the chapter you get introduced to troff, which originated from roff, which was then adapter to nroff to support more features and be programmable.

troff is used as a formatting macro language, sort of like markdown today (or bbcode here on the forums), where you define big blocks such as headers, title, pagination, paragraphs, etc..
And it has many standards and format, mm(newer System V) and ms (standard).

However, troff on itself doesn't support everything and you have to combine it with other tools such as tbl and eqn, for tables and math equations respectively.

troff syntax is made up of commands that start with a dot (.) followed by 1 or 2 letters or digit and maybe a parameter along with them.


.ft B
Bold font

Or the command can be within the text itself when they begin with \, for example \fB to switch font to bold.

Then you can generate a neat document that looks really clean. I've used groff on my machine:

groff -ms -T pdf > hoc.pdf

As for tbl, it processes things between the command:


And for eqn for equations between
.EQ and .EN

Then you can create a pipeline to process all this:

tbl | eqn -Tpdf | groff -ms -T pdf > hoc.pdf && xdg-open hoc.pdf

NB: In the code I've used `inf` instead of infinity.

Additionally you have other things you can add to the pipeline such as the refer command for bibliography.

Troff can be used to write manpages. The man command is a printer for man pages, it finds them from /usr/man directory and uses nroff or troff with a macro package to print them.

Interestingly the man command used to be a shell script. It's weird how many of the commands used to be shell scripts and now they are compiled binaries. It was much simpler to inspect what programs do at the time, explore to discover. I think that might be because of licenses related issues.

They give us a typical layout for a man page but basically there's nothing enforcing it other than goodwill. but at least command name and section should be there.

Bunch of useful commands mentioned:
  • refer(1) to look up references and cite authors
  • pic(1) to insert pictures/diagrams
  • spell(1) to check spelling errors
  • style(1)
  • diction(1)

[b]Chapter 10[b/] Epilogue

The epilogue tries to answer the question of why Unix systems got popular. Is it because talented people created an environment that is good for development?
Then, as usual, growth leads to the insertion of ill-designed software, creeping featurism.

Maybe it's because of the programming style that is encouraged on unix-like systems, one that (like phillbush also summarizes):
1. Let machine do the work
2. Let others do the work
3. Do the job in stages
4. Build tools

Unix system leave room for trial and errors, it is not burdened like big operating systems.

Messages In This Thread
RE: Nixers Book Club - Book #1: The UNIX Programming Environment - by venam - 10-01-2021, 12:09 PM