43.20 Displaying a troff Macro DefinitionIf you're writing or debugging troff macros ( 43.13 ) , you often need to review the contents of a macro. Rather than searching through the macro definition files with an editor, it is relatively easy to construct a small script that uses sed ( 34.24 ) and the shell to extract and display a single macro.
The script is easy to construct because the macro definitions have a
regular structure that lends itself to easy identification with the
regular expressions (
26.4
)
used by
sed
.
A
troff
macro definition always begins with the string troff macros are defined in a macro package, often a single file that's located in a directory such as /usr/lib/tmac . The most common macro packages are mm , ms and me -though it is unlikely that a given system will have all three. mm is generally found on System V-derived systems, and ms and me on BSD-derived systems. The man macros are found on just about all systems because they are used by the man command ( 50.1 ) . Here's an example:
% The getmac script is below. For those unfamiliar with sed , there are comments in the script on the CD-ROM (and in the online archive file):
- , |
|