March 20th, 2008

regency cards

Terminfo vs. TERMCAP

Over the last year or so, I've spent quite a number of hours fighting with the terminfo system to get certain tools I use on assorted systems I log in to to be able to send information to the status line (usually the title bar in xterm and most other terminal emulators). This has been a struggle primarily because certain RedHat derivatives ship with a terminfo database containing a broken information file for screen (lacking definitions for tsl and fsl). I finally learned that you can augment the terminfo database with local settings in your homedir (this they got right). At this point I feel I've learned quite a bit about terminfo and its predecessor, TERMCAP, and I have a simple question:

Why the hell did we go from TERMCAP to terminfo?

terminfo stores a static database of all the capabilities of every terminal which might ever be encountered. If you use a new terminal (that is, one with an unknown name), the database must be augmented with its capabilities. Why the inflexibility? Now that I'm trying out a relatively obscure terminal emulator (rxvt-unicode), and typically run it under screen, I pretty much have to create ~/.terminfo/r/rxvt-unicode and ~/.terminfo/s/screen.rxvt-unicode on every system I connect to. And if I connect to a system which doesn't give me a homedir for some reason, I'm pretty much screwed (or have to remember to lie about what TERM I'm using before I connect).

Compare with TERMCAP. The terminal informs the login shell of its capabilities through an environment variable. This means that if it's configured with different capabilities than the stock (say I've enabled/disabled colors differently from the expectation), it can inform the system. And if it's a brand-new terminal, the system doesn't have to have heard of it. I wouldn't have to go to drop files on every system I connect to letting them know about my terminal.

Yeah, there are severe problems with the TERMCAP approach (environment variables are often limited in length), but when they reinvented the wheel to overcome the limitations, what the hell were they thinking in taking away the most useful feature, the ability for the terminal to inform anything which cares about its capabilities, rather than the system having to know about every possible terminal?

Seriously, does anybody have any insight on this?