51

After downloading the source code for Bash, I was browsing through the doc directory and came across the following files:

These control characters are not displayed in the representation provided by the Git web interface but the actual file can be downloaded and examined in text editor such as Vim.

Running the file command on bash.0 prints the following output:

bash.0: ASCII text, with overstriking

I’ve never come across this file format before and I was wondering what its purpose is and how it’s used. Searching the Web for the phrase “ASCII text, with overstriking” hasn’t been very enlightening.

3 Answers 3

48

Overstriking is a method used in nroff (see the Troff User’s Manual) to offer more typographical possibilities than plain ASCII would allow:

  • bold text (by overstriking the same character)
  • underlined text (by overstriking _)
  • accents and diacritics (e.g. é produced by overstriking e with )

and various other symbols, as permitted by the target output device.

In bash, these .0 files are produced directly by nroff, with Makefile rules such as

.1.0:
        $(RM) $@
        -${NROFF} -man $< > $@

You can view such files using less; it will process the overstriking sequences and replace them as appropriate:

less bash.0

Originally nroff's output targeted typewriter-style output devices, which would back up every time they received a backspace character; overstriking would produce the desired visual output. As pointed out by chirlu, striking the same character twice would usually result in a bolder appearance thanks to the inevitable misalignment of the successive strikes; the increase in the amount of ink deposited would also help.

(troff targeted typesetting machines.)

1
  • "nroff's output targeted typewriter-style output devices" ... " troff targeted typesetting machines" So why are these both installed on my personal laptop? :P
    – cat
    Apr 8, 2016 at 0:03
20

A web search for "backspace" and "overstrike" would get better results.

The file is a manual page — formatted using nroff. Usually files such as bash.0 are simply generated and discarded. A while back, they were saved, to reduce work for the man program. Rather than /usr/share/man/man1, your manual pages would be read from /usr/share/man/cat1. Read the description of catman for instance.

nroff is the Unix command for formatting manual pages and other files. Back when it was first written, there were several other utilities, each with its own markup language. I've used at least a dozen different ones. But they all solved the problem of printing emphasized text in the same way: using carriage control. Backspaces are just noticeable because they are not used in other plain-text files. Tabs, carriage returns, line-feeds and form-feeds all have a role in plain text files (though form-feeds are far less important than they were originally).

nroff uses underlining to indicate italics and overstriking to represent bold. The technique is dated: it is useful for hard-copy devices where more than one character can be printed in the same position. Very few video terminals do that. In terminfo(5), that would be

   over_strike               os     os   terminal can over-
                                         strike

or more completely:

If the terminal overstrikes (rather than clearing a position when a character is struck over) then it should have the os capability.

In the usual case, the last character written on a given row/column of a video terminal would be all that is shown. nroff organized the output so that an underlined character was written as an underline, a backspace and the actual character. Doing that ensured that terminals without the overstrike feature would print something useful.

Among the very few video terminals listed which have the overstrike capability, I see the DEC gt40, which I used for about three years (1976-1979). There was no Unix on that system (it ran RT-11), but I wrote a text formatter, using the same type of overstruck text. Ultimately, I needed hardcopy, and wrote a utility to make that happen — something like col, perhaps — but solving a related problem. The terminal printed very slowly when it had a lot of underlined text, until my program reorganized the text to reduce the amount of switching between forward/backward motion.

With video terminals, there is no need for that. But they do not do overstriking. Instead, we have programs that recognize the underlining and show underlines, or have groff, which might show colored text instead of underlining (and bold).

Further reading:

1
  • 1
    Thanks for the comprehensive answer with interesting historical background. It's late at night for me so I'll read it properly tomorrow. FWIW, I actually upvoted your answer on generating man pages earlier today when I was researching the *roff family of text formatters. Apr 6, 2016 at 23:05
7

And even earlier, it was a method of printing on golf-ball printers that worked like old typewriters and had a very limited set of characters that they could print. So nroff uses the byte stream of an old teletype printer to represent how to should look 'on screen'.

2
  • nroff actually was designed initially to print on typewriters, as opposed to troff which targeted typesetters. Using screens for output came later... Apr 6, 2016 at 13:56
  • 11
    I'm old enough to have used a mechanical typewriter where you typed ! by typing ' BACKSPACE .
    – Barmar
    Apr 6, 2016 at 17:58

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .