Cursing the tput utility - the penguin strikes again
- Reply: Daniel Tameling : "Re: Cursing the tput utility - the penguin strikes again"
- Reply: Thomas Dickey : "Re: Cursing the tput utility - the penguin strikes again"
- Reply: Kurt Hackenberg : "Re: Cursing the tput utility - the penguin strikes again"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 23 Feb 2023 16:45:21 UTC
I'm looking at another documentation snafu here. So there's a tput utility for controlling the terminal in BSD. It takes "attributes" and arguments and outputs whatever control codes are needed to make the terminal do what you need in a portable way (switch to bold, move the cursor, clear to EOL or whatever). It doesn't matter if you're using an VT52 terminal or xterm - tput does the translation. What the man page talks about as "attributes" are actually tcap codes - there's a list of them under "man 5 terminfo". So, to move the cursor to the top left use "tcap cm 0 0 " - "cm" being the tcap code for Cursor Move. The location and format of the database in the man page is way off mark, but never mind. So what's my problem? 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. So for example, "cm" becomes "cup", and "ce" (Clear End-of-line) is "el". On a Linux you probably need to use "tcap cup 0 0" instead of "tcap cm 0 0. So my question is, assuming one wants one's scripts to be compatible with Linux, what's the best way of going about it? Is there some new platform-independent way of doing this I'm too old to know about, or do you really have to write shell scripts to cope with both by defining the code to use up front based on the output of uname? I can figure this out - I just want to know if there's a "best practice" solution before rolling my own. If anyone reading expresses an interest I might put the best answer I can find in a blog post. Thanks, Frank.