GROFFER(1) | General Commands Manual | GROFFER(1) |
groffer - display groff files and man pages on X and tty
groffer |
[mode-option ...] [groff-option ...] [man-option ...] [X-option ...] [--] [filespec ...] |
groffer |
-h |
groffer |
--help |
groffer |
-v |
groffer |
--version |
The groffer program is the easiest way to use groff(1). It can display arbitrary documents written in the groff language, see groff(7), or other roff languages, see roff(7), that are compatible to the original troff language. It finds and runs all necessary groff preprocessors, such as chem.
The groffer program also includes many of the features for finding and displaying the Unix manual pages (man pages), such that it can be used as a replacement for a man(1) program. Moreover, compressed files that can be handled by gzip(1) or bzip2(1) are decompressed on-the-fly.
The normal usage is quite simple by supplying a file name or name of a man page without further options. But the option handling has many possibilities for creating special behaviors. This can be done either in configuration files, with the shell environment variable GROFFER_OPT, or on the command line.
The output can be generated and viewed in several different ways available for groff. This includes the X Window System-based groff program gxditview(1), each PostScript, PDF, or DVI display program, a web browser by generating HTML or XHTML in www mode, or several text modes in text terminals.
Most of the options that must be named when running groff directly are determined automatically for groffer, due to the internal usage of the grog(1) program. But all parts can also be controlled manually by arguments.
Several file names can be specified on the command-line arguments. They are transformed into a single document in the normal way of groff.
Option handling is done in GNU style. Options and file names can be mixed freely. The option “--” closes the option handling, all following arguments are treated as file names. Long options can be abbreviated in several ways.
|
[-h | --help] [-v | --version] |
|
[--auto] [--default] [--default-modes mode1,mode2,...] [--dvi] [--groff] [--html] [--latin1] [--mode display_mode] [--pdf] [--pdf2] [--ps] [--source] [--text] [--to-stdout] [--tty] [--utf8] [--viewer prog] [--www] [--xhtml] [--x | --X] |
|
[-T | --device device] [-Z | --intermediate-output | --ditroff] |
All further groff short options are accepted.
|
[--apropos] [--apropos-data] [--apropos-devel] [--apropos-progs] [--man] [--no-man] [--no-special] [--whatis] |
|
[--all] [--ascii] [--ditroff] [--extension suffix] [--locale language] [--local-file] [--location | --where] [--manpath dir1:dir2:...] [--no-location] [--pager program] [--sections sec1:sec2:...] [--systems sys1,sys2,...] [--troff-device device] |
Further long options of GNU man are accepted as well.
|
[--bd | --bordercolor pixels] [--bg | --background color] [--bw | --borderwidth pixels] [--display X-display] [--fg | --foreground color] [--fn | --ft | --font font_name] [--geometry size_pos] [--resolution value] [--rv] [--title string] [--xrm X-resource] |
|
[--debug] [--debug-filenames] [--debug-grog] [--debug-keep] [--debug-params] [--debug-tmpdir] [--do-nothing] [--print text] [-V] |
The filespec parameters are all arguments that are neither an option nor an option argument. They usually mean a file name or a man page searching scheme.
In the following, the term section_extension is used. It means a word that consists of a man section that is optionally followed by an extension. The name of a man section is a single character from [1–9on], the extension is some word. The extension is mostly lacking.
No filespec parameters means standard input.
The groffer program can usually be run with very few options. But for special purposes, it supports many options. These can be classified in 5 option classes.
All short options of groffer are compatible with the short options of groff(1). All long options of groffer are compatible with the long options of man(1).
Arguments for long option names can be abbreviated in several ways. First, the argument is checked whether it can be prolonged as is. Furthermore, each minus sign - is considered as a starting point for a new abbreviation. This leads to a set of multiple abbreviations for a single argument. For example, --de-n-f can be used as an abbreviation for --debug-not-func, but --de-n works as well. If the abbreviation of the argument leads to several resulting options an error is raised.
These abbreviations are only allowed in the environment variable GROFFER_OPT, but not in the configuration files. In configuration, all long options must be exact.
As soon as one of these options is found on the command line it is executed, printed to standard output, and the running groffer is terminated thereafter. All other arguments are ignored.
The display mode and the viewer programs are determined by these options. If none of these mode and viewer options is specified groffer tries to find a suitable display mode automatically. The default modes are mode pdf, mode ps, mode html, mode xhtml, mode x, and mode dvi in the X Window System with different viewers and mode tty with device utf8 under less on a terminal; other modes are tested if the programs for the main default mode do not exist.
In the X Window System, many programs create their own window when called. groffer can run these viewers as an independent program in the background. As this does not work in text mode on a terminal (tty) there must be a way to know which viewers are X Window System-based graphical programs. The groffer script has a small amount of information on some viewer names. If a viewer argument of the command-line chooses an element that is recognized as an X Window System-based program in this list, it is treated as a viewer that can run in the background. Unrecognized viewers are not run in the background.
For each mode, you are free to choose whatever viewer you want. That need not be some graphical viewer suitable for this mode. There is a chance to view the output source; for example, the combination of the options --mode=ps and --viewer=less shows the content of the PostScript output, the source code, with the pager less.
The following modes do not use the groffer viewing features. They are only interesting for advanced applications.
Besides these, groffer accepts all short options that are valid for the groff(1) program. All non-groffer options are sent unmodified via grog to groff. So postprocessors, macro packages, compatibility with classical troff, and much more can be manually specified.
All short options of groffer are compatible with the short options of groff(1). The following of groff options have either an additional special meaning within groffer or make sense for normal usage.
Because of the special outputting behavior of the groff option -Z groffer was designed to be switched into groff mode; the groffer viewing features are disabled there. The other groff options do not switch the mode, but allow to customize the formatting process.
All other groff options are supported by groffer, but they are just transparently transferred to groff without any intervention. The options that are not explicitly handled by groffer are transparently passed to groff. Therefore these transparent options are not documented here, but in groff(1). Due to the automatism in groffer, none of these groff options should be needed, except for advanced usage.
The following options were added to groffer for choosing whether the file name arguments are interpreted as names for local files or as a search pattern for man pages. The default is looking up for local files.
The long options of groffer were synchronized with the long options of GNU man. All long options of GNU man are recognized, but not all of these options are important to groffer, so most of them are just ignored. These ignored man options are --catman, --troff, and --update.
In the following, the man options that have a special meaning for groffer are documented.
If your system has GNU man installed the full set of long and short options of the GNU man program can be passed via the environment variable MANOPT; see man(1).
The following long options were adapted from the corresponding X Window System Toolkit Intrinsics options. groffer will pass them to the actual viewer program if it is an X Window System program. Otherwise these options are ignored.
Unfortunately these options use the old style of a single minus for long options. For groffer that was changed to the standard with using a double minus for long options, for example, groffer uses the option --font for the X Window System Toolkit Intrinsics option -font.
See X(7) and the manual X Toolkit Intrinsics – C Language Interface for more details on these options and their arguments.
Other useful debugging options are the groff option -Z and --mode=groff.
A filespec parameter is an argument that is not an option or option argument. In groffer, filespec parameters are a file name or a template for searching man pages. These input sources are collected and composed into a single output file such as groff does.
The strange POSIX behavior to regard all arguments behind the first non-option argument as filespec arguments is ignored. The GNU behavior to recognize options even when mixed with filespec arguments is used throughout. But, as usual, the double minus argument -- ends the option handling and interprets all following arguments as filespec arguments; so the POSIX behavior can be easily adopted.
The options --apropos* have a special handling of filespec arguments. Each argument is taken as a search scheme of its own. Also a regexp (regular expression) can be used in the filespec. For example, groffer --apropos '^gro.f$' searches groff in the man page name, while groffer --apropos groff searches groff somewhere in the name or description of the man pages.
All other parts of groffer, such as the normal display or the output with --whatis have a different scheme for filespecs. No regular expressions are used for the arguments. The filespec arguments are handled by the following scheme.
It is necessary to know that on each system the man pages are sorted according to their content into several sections. The classical man sections have a single-character name, either a digit from 1 to 9 or one of the characters n or o.
This can optionally be followed by a string, the so-called extension. The extension allows the storage of several man pages with the same name in the same section. But the extension is only rarely used; usually it is omitted. Then the extensions are searched automatically by alphabet.
In the following, we use the name section_extension for a word that consists of a single character section name or a section character that is followed by an extension. Each filespec parameter can have one of the following forms in decreasing sequence.
Several file name arguments can be supplied. They are mixed by groff into a single document. Note that the set of option arguments must fit to all of these file arguments. So they should have at least the same style of the groff language.
By default, the groffer program collects all input into a single file, formats it with the groff program for a certain device, and then chooses a suitable viewer program. The device and viewer process in groffer is called a mode. The mode and viewer of a running groffer program is selected automatically, but the user can also choose it with options. The modes are selected by option the arguments of --mode=anymode. Additionally, each of this argument can be specified as an option of its own, such as anymode. Most of these modes have a viewer program, which can be chosen by the option --viewer.
Several different modes are offered: graphical modes for the X Window System, text modes, and some direct groff modes for debugging and development.
By default, groffer first tries whether x mode is possible, then ps mode, and finally tty mode. This mode testing sequence for auto mode can be changed by specifying a comma separated list of modes with the option --default-modes.
The searching for man pages and the decompression of the input are active in every mode.
The graphical display modes work mostly in the X Window System environment (or similar implementations within other windowing environments). The environment variable DISPLAY and the option --display are used for specifying the X Window System display to be used. If this environment variable is empty, groffer assumes that the X Window System is not running and changes to a text mode. You can change this automatic behavior by the option --default-modes.
Known viewers for the graphical display modes and their standard X Window System viewer programs are
The pdf mode has a major advantage — it is the only graphical display mode that allows searching for text within the viewer; this can be a really important feature. Unfortunately, it takes some time to transform the input into the PDF format, so it was not chosen as the major mode.
These graphical viewers can be customized by options of the X Window System Toolkit Intrinsics. But the groffer options use a leading double minus instead of the single minus used by the X Window System Toolkit Intrinsics.
There are two modes for text output, mode text for plain output without a pager and mode tty for a text output on a text terminal using some pager program.
If the variable DISPLAY is not set or empty, groffer assumes that it should use tty mode.
In the actual implementation, the groff output device latin1 is chosen for text modes. This can be changed by specifying option -T or --device.
The pager to be used can be specified by one of the options --pager and --viewer, or by the environment variable PAGER. If all of this is not used the less(1) program with the option -r for correctly displaying control sequences is used as the default pager.
These modes use the groffer file determination and decompression. This is combined into a single input file that is fed directly into groff with different strategy without the groffer viewing facilities. These modes are regarded as advanced, they are useful for debugging and development purposes.
The source mode with option --source just displays the decompressed input.
Option --to-stdout does not display in a graphical mode. It just generates the file for the chosen mode and then prints its content to standard output.
The groff mode passes the input to groff using only some suitable options provided to groffer. This enables the user to save the generated output into a file or pipe it into another program.
In groff mode, the option -Z disables post-processing, thus producing the groff intermediate output. In this mode, the input is formatted, but not postprocessed; see groff_out(5) for details.
All groff short options are supported by groffer.
The default behavior of groffer is to first test whether a file parameter represents a local file; if it is not an existing file name, it is assumed to represent the name of a man page. The following options can be used to determine whether the arguments should be handled as file name or man page arguments.
If neither a local file nor a man page was retrieved for some file parameter a warning is issued on standard error, but processing is continued.
Let us now assume that a man page should be searched. The groffer program provides a search facility for man pages. All long options, all environment variables, and most of the functionality of the GNU man(1) program were implemented. The search algorithm shall determine which file is displayed for a given man page. The process can be modified by options and environment variables.
The only man action that is omitted in groffer are the preformatted man pages, also called cat pages. With the excellent performance of the actual computers, the preformatted man pages aren't necessary any longer. Additionally, groffer is a roff program; it wants to read roff source files and format them itself.
The algorithm for retrieving the file for a man page needs first a set of directories. This set starts with the so-called man path that is modified later on by adding names of operating system and language. This arising set is used for adding the section directories which contain the man page files.
The man path is a list of directories that are separated by colon. It is generated by the following methods.
We now have a starting set of directories. The first way to change this set is by adding names of operating systems. This assumes that man pages for several operating systems are installed. This is not always true. The names of such operating systems can be provided by 3 methods.
Several names of operating systems can be given by appending their names, separated by a comma.
The man path is changed by appending each system name as subdirectory at the end of each directory of the set. No directory of the man path set is kept. But if no system name is specified the man path is left unchanged.
After this, the actual set of directories can be changed by language information. This assumes that there exist man pages in different languages. The wanted language can be chosen by several methods.
The default language can be specified by specifying one of the pseudo-language parameters C or POSIX. This is like deleting a formerly given language information. The man pages in the default language are usually in English.
Of course, the language name is determined by man. In GNU man, it is specified in the POSIX 1003.1 based format:
<language>[_<territory>[.<character-set>[,<version>]]],
but the two-letter code in <language> is sufficient for most purposes. If for a complicated language formulation no man pages are found groffer searches the country part consisting of these first two characters as well.
The actual directory set is copied thrice. The language name is appended as subdirectory to each directory in the first copy of the actual directory set (this is only done when a language information is given). Then the 2-letter abbreviation of the language name is appended as subdirectories to the second copy of the directory set (this is only done when the given language name has more than 2 letters). The third copy of the directory set is kept unchanged (if no language information is given this is the kept directory set). These maximally 3 copies are appended to get the new directory set.
We now have a complete set of directories to work with. In each of these directories, the man files are separated in sections. The name of a section is represented by a single character, a digit between 1 and 9, or the character o or n, in this order.
For each available section, a subdirectory man<section> exists containing all man files for this section, where <section> is a single character as described before. Each man file in a section directory has the form man<section>/<name>.<section>[<extension>][.<compression>], where <extension> and <compression> are optional. <name> is the name of the man page that is also specified as filespec argument on the command line.
The extension is an addition to the section. This postfix acts like a subsection. An extension occurs only in the file name, not in name of the section subdirectory. It can be specified on the command line.
On the other hand, the compression is just an information on how the file is compressed. This is not important for the user, such that it cannot be specified on the command line.
There are 4 methods to specify a section on the command line:
It is also possible to specify several sections by appending the single characters separated by colons. One can imagine that this means to restrict the man page search to only some sections. The multiple sections are only possible for MANSECT and --sections.
If no section is specified all sections are searched one after the other in the given order, starting with section 1, until a suitable file is found.
There are 4 methods to specify an extension on the command line. But it is not necessary to provide the whole extension name, some abbreviation is good enough in most cases.
For further details on man page searching, see man(1).
sh# groffer groffNo section is specified here, so all sections should be searched, but as section 1 is searched first this file will be found first. The file name is composed of the following components. /usr/share/man/ must be part of the man path; the subdirectory man1/ and the part .1 stand for the section; groff is the name of the man page.
sh# groffer groff.7 sh# groffer 7 groff sh# groffer --sections=7 groff
sh# groffer ctags.1e sh# groffer 1e ctags sh# groffer --extension=e --sections=1 ctagswhere e works as an abbreviation for the extension emacs21.
sh# groffer --locale=de --sections=5:7 --systems=linux,aix man sh# LANG=de MANSECT=5:7 SYSTEM=linux,aix groffer man
The program has a decompression facility. If standard input or a file that was retrieved from the command line parameters is compressed with a format that is supported by either gzip(1) or bzip2(1) it is decompressed on-the-fly. This includes the GNU .gz, .bz2, and the traditional .Z compression. The program displays the concatenation of all decompressed input in the sequence that was specified on the command line.
The groffer program supports many system variables, most of them by courtesy of other programs. All environment variables of groff(1) and GNU man(1) and some standard system variables are honored.
The following variables have a special meaning for groffer.
sh# DISPLAY=:0.1 groffer what.ever &
sh# PAGER=cat groffer anything
The groffer program internally calls groff, so all environment variables documented in groff(1) are internally used within groffer as well. The following variable has a direct meaning for the groffer program.
Parts of the functionality of the man program were implemented in groffer; support for all environment variables documented in man(1) was added to groffer, but the meaning was slightly modified due to the different approach in groffer; but the user interface is the same. The man environment variables can be overwritten by options provided with MANOPT, which in turn is overwritten by the command line.
The environment variable MANROFFSEQ is ignored by groffer because the necessary preprocessors are determined automatically.
The groffer program can be preconfigured by two configuration files.
Both files are handled for the configuration, but the configuration file in /etc comes first; it is overwritten by the configuration file in the home directory; both configuration files are overwritten by the environment variable GROFFER_OPT; everything is overwritten by the command line arguments.
The configuration files contain options that should be called as default for every groffer run. These options are written in lines such that each contains either a long option, a short option, or a short option cluster; each with or without an argument. So each line with configuration information starts with a minus character “-”; a line with a long option starts with two minus characters “--”, a line with a short option or short option cluster starts with a single minus “-”.
The option names in the configuration files may not be abbreviated, they must be exact.
The argument for a long option can be separated from the option name either by an equal sign “=” or by whitespace, i.e. one or several space or tab characters. An argument for a short option or short option cluster can be directly appended to the option name or separated by whitespace. The end of an argument is the end of the line. It is not allowed to use a shell environment variable in an option name or argument.
It is not necessary to use quotes in an option or argument, except for empty arguments. An empty argument can be provided by appending a pair of quotes to the separating equal sign or whitespace; with a short option, the separator can be omitted as well. For a long option with a separating equal sign “=”, the pair of quotes can be omitted, thus ending the line with the separating equal sign. All other quote characters are cancelled internally.
In the configuration files, arbitrary whitespace is allowed at the beginning of each line, it is just ignored. Each whitespace within a line is replaced by a single space character “ ” internally.
All lines of the configuration lines that do not start with a minus character are ignored, such that comments starting with “#” are possible. So there are no shell commands in the configuration files.
As an example, consider the following configuration file that can be used either in /etc/groff/groffer.conf or ~/.groff/groffer.conf .
# groffer configuration file # # groffer options that are used in each call of groffer --foreground=DarkBlue --resolution=100 --viewer=gxditview -geometry 900x1200
The lines starting with # are just ignored, so they act as command lines. This configuration sets four groffer options (the lines starting with “-”). This has the following effects:
The usage of groffer is very easy. Usually, it is just called with a file name or man page. The following examples, however, show that groffer has much more fancy capabilities.
sh# groffer /usr/local/share/doc/groff/meintro.ms.gz
Decompress, format and display the compressed file meintro.ms.gz in the directory /usr/local/share/doc/groff, using the standard viewer gxditview as graphical viewer when in the X Window System, or the less(1) pager program otherwise.
sh# groffer groff
If the file ./groff exists use it as input. Otherwise interpret the argument as a search for the man page named groff in the smallest possible man section, being section 1 in this case.
sh# groffer man:groff
search for the man page of groff even when the file ./groff exists.
sh# groffer groff.7 sh# groffer 7 groff
search the man page of groff in man section 7. This section search works only for a digit or a single character from a small set.
sh# groffer fb.modes
If the file ./fb.modes does not exist interpret this as a search for the man page of fb.modes. As the extension modes is not a single character in classical section style the argument is not split to a search for fb.
sh# groffer groff ’troff(1)’ man:roff
The arguments that are not existing files are looked-up as the following man pages: groff (automatic search, should be found in man section 1), troff (in section 1), and roff (in the section with the lowest number, being 7 in this case). The quotes around ’troff(1)’ are necessary because the parentheses are special shell characters; escaping them with a backslash character \( and \) would be possible, too. The formatted files are concatenated and displayed in one piece.
sh# LANG=de groffer --man --viewer=galeon ls
Retrieve the German man page (language de) for the ls program, decompress it, format it to html or xhtml format (www mode) and view the result in the web browser galeon. The option --man guarantees that the man page is retrieved, even when a local file ls exists in the actual directory.
sh# groffer --source 'man:roff(7)'
Get the man page called roff in man section 7, decompress it, and print its unformatted content, its source code.
sh# groffer --de-p --in --ap
This is a set of abbreviated arguments, it is determined as
sh# groffer --debug-params --intermediate-output --apropos
sh# cat file.gz | groffer -Z -mfoo
The file file.gz is sent to standard input, this is decompressed, and then this is transported to the groff intermediate output mode without post-processing (groff option -Z), using macro package foo (groff option -m).
sh# echo '\f(CBWOW!' | > groffer --x --bg red --fg yellow --geometry 200x100 -
Display the word WOW! in a small window in constant-width bold font, using color yellow on red background.
The groffer program is written in Perl, the Perl version during writing was v5.8.8.
groffer provides its own parser for command-line arguments that is compatible to both POSIX getopts(1) and GNU getopt(1). It can handle option arguments and file names containing white space and a large set of special characters. The following standard types of options are supported.
sh# groffer file1 -a -o arg file2
is equivalent to
sh# groffer -a -o arg -- file1 file2
The free mixing of options and filespec parameters follows the GNU principle. That does not fulfill the strange option behavior of POSIX that ends option processing as soon as the first non-option argument has been reached. The end of option processing can be forced by the option “--” anyway.
groffer was written by Bernd Warken.
19 March 2021 | groff 1.22.4 |