2015/09/11

TERM is fundamentally broken

The use of TERM is a poor choice for any design. We could argue it was okay in the dim dark days of PDP-11s and VAXen, but by now, we should know better.

Which is why COLORTERM is even dumber.

So why is it a bad choice?  Easy; it's presenting the wrong information.  Even worse it forces developers to lie to provide the right information.

So lets take a step back; why do applications use TERM?  So they know what features the terminal supports (colour, cursor movement, resizing, scrolling, animated tractors).  How do they know that?

Easy; they take the name of the terminal, look it up in a local database, so they can see if and how the features they need work.  Welcome to the wonderful world of termcap.  It's even better when you discover it's limited to 1024 bytes per entry, and everything is shoved in 2 byte keys.

Hopefully your local database has the terminal you have set; else... well you need to assume.

So say you have a new terminal type - the metaterm.  It does everything the common superterm does. But your metaterm isn't in any databases (it's new).  You have two choices, either you pretend to be a superterm and set some other channel to provide information to the things that know how to use metaterm or you claim to be a metaterm and deal with the fact that many applications won't work correctly as either a superterm or a metaterm.

Both answers suck.

Providing a list of capabilities is the way to go.  Then the application can see what capabilities are available from the ones it cares about.  Everything gracefully degrades and both new and old applications don't need to play a stupid dance about compatibility and lying about what is what.

Of course for most people we can do even better.  Maybe my next post.

No comments: