tctest − termcap library checker


tctest [options] [file-specifications]


tctest exercises the termcap library (or emulation of termcap) with which it is linked. It provides several command-line options, making it simple to construct test-cases to compare implementations of termcap.


After processing options, tctest uses any command-line parameters as the names of terminal descriptions to process. If no command-line parameters are given, tctest tries the TERM environment variable. If that is not set, the program uses the dumb terminal description.

The termcap library function tgetent locates the termcap file, looking at the TERMCAP environment variable (or /etc/termcap). tctest manipulates this environment variable, allowing one to use alternate terminal databases.

Some of the options provide only summary behavior. The most useful output from tctest is in termcap format, with one capability per line. It is noted that the extra whitespace would be poorly handled by some termcap implementations, counting toward the 1023 byte limit on an entry’s size. The reason for listing it in this way is to provide easy comparison.

These are the options:


when processing a termcap file, e.g., with −a, call tgetent only once per entry using the primary name. Use this for getting per-entry statistics versus the per-call statistics.


show capabilities for all names in termcap file. This overrides the −b option.


use brute-force to find all capabilities, e.g., for the names given on the command-line.


tctest uses the names from a built-in table of termcap names chosen to correspond to terminfo capability names. This is the default; the −c option is provided to cancel −b.


use $TERMCAP variable if it exists. If this option is not set, tctest unsets the TERMCAP environment variable.


use this termcap file. tctest sets the TERMCAP environment variable to the file’s absolute path.


writes two files (by-name.dat and by-size.dat) with statistics gathered while processing other options, e.g., −a or −s):

by-name.dat columns


the 2-character capability name in double-quotes


total number of times the capability was retrieved


number denoting if the value is "standard" (1) or "obsolete" (3).

by-size.dat columns


size of the buffer returned by tgetent


total number of tgetent calls returning this size


total wasted space (tabs, newlines) for tgetent calls returning this size


list names and aliases in termcap file.


do not query for the capability names. This option is used to allow timing "only" tgetent.


redirect output (the reformatted input) to this file. By default that goes to the standard output. If this option is used, verbose and summary reports are written to the standard output instead of the standard error, to allow separating them from error messages that may be written by the termcap library.


repeat the processing of the terminal database this many times. As in −n, this is used to help measure timing for tgetent.


show a summary report.


verbose (prints names to stderr to track tgetent calls). This is useful in conjunction with −a, e.g., to help pinpoint places where tgetent reports that a terminal entry is too large. Repeat the option to get more detail.


check the result from tgetent and tgetstr, printing warnings to the standard error.


print the program version and exit


tgetent(3) documentation for ncurses highlights the differences. This is a starting point; although the original BSD source code is recommended reading as well.

ncurses(3) is a terminfo-based library, which provides a termcap interface. Normally it ignores the TERMCAP variable, but it can be configured to provide a more accurate emulation of the termcap library, e.g., loading the terminal entries base on TERMCAP.


Thomas Dickey <>.