Re: Cursing the tput utility - the penguin strikes again
- In reply to: Frank Leonhardt : "Re: Cursing the tput utility - the penguin strikes again"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 23 Feb 2023 23:30:45 UTC
On Thu, Feb 23, 2023 at 09:20:10PM +0000, Frank Leonhardt wrote: > On 23/02/2023 20:26, Thomas Dickey wrote: > > On Thu, Feb 23, 2023 at 03:14:16PM -0500, Kurt Hackenberg wrote: > > > On Thu, Feb 23, 2023 at 04:45:21PM +0000, Frank Leonhardt wrote: > > > > > > > So there's a tput utility for controlling the terminal in BSD. > > > ... > > > > Well use the tcap utility on non-BSD platforms and it suddenly doesn't > > > > work. It turns out that the penguinistas thought using the "Cap Name" > > > > instead of the "TCap Code" was a good idea. Some of the codes are the > > > > same, some are not. In fact most are not. > > > The trouble is those are two different mechanisms, based on two different > > > file formats, that do the same thing. > > > > > > The two file formats are "termcap" and "terminfo", both from the default > > > names of the system files that use them. Manual section 5 has pages about > > > both. They're similar, but different enough to be incompatible. > > > > > > The "TCap codes" are the names used in termcap format; the "Capnames" are > > > the names used in terminfo format. (A "cap" is a terminal "capability".) > > > > > > I think termcap came first, and then somebody invented terminfo as an > > > improvement or a reimplementation of the same idea. I think termcap came > > > from Berkeley Unix -- maybe invented for vi -- so FreeBSD more or less > > > stayed with it. Maybe terminfo came from Bell Labs; I think Linux prefers > > > it. > > most do (FreeBSD's userland is an exception) > > > > It's actually ncurses (and terminfo) underneath the facade. > > > > related - > > > > https://invisible-island.net/ncurses/tctest.html > > > This is pointlessly incompatible, the result of haphazard evolution, and > > > kind of a mess. It's all about 40 years old. > > > > > > The library functions that use those terminal descriptions were in the > > > library "curses" (from "cursor"), long ago superseded by "ncurses" (new > > > curses). Probably the program tput uses the library ncurses. You > > > might want > > > to look at that library; maybe there's a compatibility layer. Or, as > > > Daniel > > > Tameling suggested, maybe there are two different version of ncurses. > > just one - > > > > https://invisible-island.net/ncurses/ncurses.faq.html#platform-portable > > > > (but reading the FreeBSD sources would tell more) > > The info you and Kurt have posted chimes with what I believe too. I started > with System V ;-) I'm a little older than that - https://invisible-island.net/personal/oldprogs.html https://invisible-island.net/personal/twenties.html > It's pretty clear that BSD has stuck with termcap where tput is concerned. > Linux has broken this by using terminfo names instead. BSD presumably uh - no: tput was around for 5+ years before Keith Bostic adapted the command name to 4.3BSD (SVr4 was released in April 1984, with code from a year or more before, while Bostic's tput dates from October 1989 -- replacing a "clear" program - if you look at the SCCS history, you'll see _that_). Linux happens to do what the vendor-Unix systems do/did (Solaris, HP-UX, AIX, IRIX/IRIX64, SCO, OSF1/Tru64). Ultimately that's because terminfo has a lot more customizability than termcap. My page on tctest gives a lot more information than you'll find in other places :-) > didn't, for compatibility. I accept no excuses for breaking things unless BSD didn't, for the obvious reason that it had no terminfo library. Bostic used termcap names, because that was what he had at hand. Once ncurses was available, Keith Bostic used that. It's a long story. > it's absolutely necessary - so anyone reading this has been warned! > > I'm pretty sure (but don't quote me) that termcap came from the BSD side (I > don't remember it on other Unix systems); terminfo was supposed to include > printer control codes as well, and I think it was there on SunOS (also BSD. > Hmm) SunOS was basically 4.2BSD (for a starting point). A lot of that never changed (Sun didn't adopt improvements from 4.3BSD, though of course Sun did its _own_ improvements). I recall reading some details on contributions from Sun to 4.3BSD, but don't know of an accurate source of information to use as a tutorial. SunOS 4 did have a terminfo manpage, as part of System V compatibility. The manpage terminfo(5V) notes SYNOPSIS /usr/share/lib/terminfo/?/∗ AVAILABILITY This database is available with the System V software installation op‐ tion. Refer to for information on how to install optional software. The terminfo and termcap functions for SunOS 4 are documented in the curses manpage. It has a separate termcap.3x manpage, but no corresponding separate terminfo manpage. You may recall that Sun worked with AT&T to develop Solaris. > Unless anything comes up I can see two solutions - a compatibility wrapper > for shell scripts or, perhaps, modifying BSD tput to accept both versions of > the attribute name. Something to think about... I seem to recall that there's one ambiguity doing that, but don't see it offhand in terminfo(5). -- Thomas E. Dickey <dickey@invisible-island.net> https://invisible-island.net