From nobody Thu Feb 23 21:20:10 2023 X-Original-To: questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PN5XD4Py8z3smJ7 for ; Thu, 23 Feb 2023 21:20:12 +0000 (UTC) (envelope-from freebsd-doc@fjl.co.uk) Received: from bs1.fjl.org.uk (bs1.fjl.org.uk [84.45.41.196]) by mx1.freebsd.org (Postfix) with ESMTP id 4PN5XC6YY5z3JxV for ; Thu, 23 Feb 2023 21:20:11 +0000 (UTC) (envelope-from freebsd-doc@fjl.co.uk) Authentication-Results: mx1.freebsd.org; dkim=none; spf=pass (mx1.freebsd.org: domain of freebsd-doc@fjl.co.uk designates 84.45.41.196 as permitted sender) smtp.mailfrom=freebsd-doc@fjl.co.uk; dmarc=none Received: from [192.168.1.126] (host81-129-137-223.range81-129.btcentralplus.com [81.129.137.223]) (authenticated bits=0) by bs1.fjl.org.uk (8.14.4/8.14.4) with ESMTP id 31NLKBch003683 for ; Thu, 23 Feb 2023 21:20:11 GMT (envelope-from freebsd-doc@fjl.co.uk) Message-ID: <2c582ca1-9f61-a894-b3c6-c91e696fd3cf@fjl.co.uk> Date: Thu, 23 Feb 2023 21:20:10 +0000 List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 From: Frank Leonhardt Subject: Re: Cursing the tput utility - the penguin strikes again To: questions@freebsd.org References: <974a81c2-a92d-7f94-5f96-869bddfe21f3@fjl.co.uk> <20230223202622.GA4604@prl-debianold-64.jexium-island.net> Content-Language: en-GB In-Reply-To: <20230223202622.GA4604@prl-debianold-64.jexium-island.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-2.75 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.90)[-0.905]; NEURAL_HAM_LONG(-0.65)[-0.648]; R_SPF_ALLOW(-0.20)[+ip4:84.45.41.196:c]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; ASN(0.00)[asn:25577, ipnet:84.45.0.0/17, country:GB]; MLMMJ_DEST(0.00)[questions@freebsd.org]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; ARC_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; DMARC_NA(0.00)[fjl.co.uk]; PREVIOUSLY_DELIVERED(0.00)[questions@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; TO_DN_NONE(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Rspamd-Queue-Id: 4PN5XC6YY5z3JxV X-Spamd-Bar: -- X-ThisMailContainsUnwantedMimeParts: N 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 ;-) 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 didn't, for compatibility.  I accept no excuses for breaking things unless 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) 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... Thanks, Frank.