Home / Alt manpages / infotocap(1)

  • infotocap(1)
  • User command
  • linux

Convert Terminfo Source to Termcap Safely with infotocap

infotocap turns a terminfo source file into a termcap text file without going anywhere near the system database. The workflow uses the ncurses-bin tools installed on this machine. Allow about ten minutes for a small conversion, including a check of the output.

Before you start

infotocap reads one or more text files of terminfo entries and writes converted termcap descriptions to standard output. It needs no root for this job. You need:

  • a readable terminfo source file, such as terminal.info;
  • a shell with enough space for the output file; and
  • a reason to target termcap, such as feeding an older tool that cannot read terminfo directly.

This guide describes ncurses 6.4 as identified by the local infotocap(1) manpage. The executable found first on this machine actually reports ncurses 6.6, so check your own version when reproducing an example:

infotocap -V

Expected output is a single version line, for example:

ncurses 6.6.20251230

The exact version is not cosmetic: translation details, warnings and the available database can all differ between ncurses builds.

1. Check the source without producing output

Start with validation. Swap in the path to your own file for terminal.info:

infotocap -c terminal.info

-c checks syntax and use references but produces no translated file. A successful run is normally silent and returns exit status zero:

if infotocap -c terminal.info; then
    echo "terminfo source is valid"
else
    echo "terminfo source needs repair" >&2
    exit 1
fi

Do not skip this check when the source came from somewhere else. A malformed entry can break the conversion, and an unresolved use reference means the result may not actually be the terminal description you intended.

2. Convert to a new file

Redirect standard output to a new path; this leaves the source untouched:

infotocap terminal.info > terminal.termcap

Check the first few lines and confirm the file is non-empty:

sed -n '1,12p' terminal.termcap
test -s terminal.termcap && echo "termcap output exists"

The output uses termcap syntax, capabilities separated by colons. A normal result may also carry comments noting that capabilities were removed or suppressed: termcap is less expressive than terminfo, so a conversion cannot keep every capability, and those comments are review items, not harmless decoration.

The converter writes to standard output by design. It does not install the result, update /etc/terminfo, or touch TERM, which makes shell redirection a genuine safety boundary. If you used the wrong output name, undo it by removing only the generated file, after checking the path:

rm -- terminal.termcap

That removes the converted copy, not the source. Do not overwrite the real destination in place until you have checked its contents and backed it up, if another program depends on it.

3. Convert only selected entries

A source file can hold several terminal types and aliases. Use -e with a comma-separated list when you only need particular names:

infotocap -e xterm,screen terminal.info > selected.termcap

A matching name or alias gets translated; everything else produces no output. Verify the requested names actually appear in the result:

grep -E '^(xterm|screen)(\||:)' selected.termcap

A slash in the -e value changes its meaning entirely: ncurses reads the value as a file containing the list. That is easy to trigger by accident with an absolute path, so stick to the comma-separated form for ordinary entry names.

4. Choose readable output when reviewing it

Termcap lines get dense fast. Add -1 to put one capability on each line, easier to diff and inspect:

infotocap -1 -e xterm terminal.info > xterm.review.termcap
sed -n '1,24p' xterm.review.termcap

Use -f when complex terminfo strings carry conditional expressions and need a more readable layout, and -w with an optional width to control wrapping. These only change presentation; they do nothing about the underlying limit that termcap cannot express all terminfo behaviour.

5. Decide how much compatibility you need

By default, infotocap behaves like tic with termcap translation switched on. The manpage documents other tic options too, including -K, -R, -r, -t, -T, -U, -v and -x.

Use -K when the consumer needs stricter BSD-style termcap syntax, and -r when preparing a file for an old termcap library that cannot follow the remaining tc references. Both choices can shift compatibility and completeness, so compare the result against the target library's own documentation before deploying it.

Do not assume a successful exit means semantic equivalence. Parameterised terminfo capabilities, for instance, can use operations termcap simply cannot represent. A useful review command is:

infotocap -C -c terminal.info

Here -C makes the translation target explicit while -c keeps the operation to checking. Warnings about values with no exact termcap equivalent are a signal to test the resulting terminal behaviour, especially cursor movement, attributes and function keys.

Common traps

  • Feeding it a compiled database entry. The input is a terminfo source file, not a binary file under /etc/terminfo. Use a source file you can read and review.
  • Overwriting the source with redirection. infotocap terminal.info > terminal.info truncates the file before the command ever reads it. Always pick a different output name.
  • Expecting installation. Conversion prints text. It installs no termcap database and hands the output to nothing else.
  • Ignoring size warnings. Traditional termcap consumers can have small entry limits. The local tool may flag an entry as too large, and an older library can misbehave with oversized data: test with the actual consumer.
  • Adding -x casually. This permits user-defined capabilities. Useful for source that intentionally uses extensions, but it does not make an unknown capability portable elsewhere.

Done means

  • Source validated: infotocap -c accepted the source with the expected exit status.
  • Output isolated: the output file is separate from the source and contains the requested entry names.
  • Warnings reviewed: you reviewed warnings about removed, suppressed or untranslatable capabilities.
  • Target tested: the target termcap consumer has actually been tested with this exact output.