From nobody Thu Feb 23 18:29:36 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 4PN1lS3lGhz3sL0n for ; Thu, 23 Feb 2023 18:29:40 +0000 (UTC) (envelope-from tamelingdaniel@gmail.com) Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PN1lR3jnjz3vJ3 for ; Thu, 23 Feb 2023 18:29:39 +0000 (UTC) (envelope-from tamelingdaniel@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=az4uouNk; spf=pass (mx1.freebsd.org: domain of tamelingdaniel@gmail.com designates 2a00:1450:4864:20::52f as permitted sender) smtp.mailfrom=tamelingdaniel@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ed1-x52f.google.com with SMTP id o12so45962953edb.9 for ; Thu, 23 Feb 2023 10:29:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=HzH07+hQ2f9XWnrNN4okuvmM0AVlC28DTm+0g0JVdKs=; b=az4uouNkQRVMycZoZUd6K9Mic2FNwLTXygpD5+9xEaz3yNIJfXRXmBK3yZau53Aj68 VhsHANyoVKVuwrsNQbr4Rx5JGjav/S+MueURzKqZ72c5nS+CsLSFeKTYpJFvuKC4Youa eWidHXI1jPi+odQUizJbzjmQV5jUAI3HJSWy4wkeWF+ArSRIqGUNA6r9Nb8EUkl00eCq 9OiF0NpwLbpGTJ2BCeQQ6klAhUZnSrmbtpOzdhYIlP0O5ocnfHiHjwtHrNbR08Y9TShK FlZSm3lIetSOYVnRoW2ssmfhNgWABaOARQkUGX+O5/FCPzIiAZmh/PYU75ntutY8Vcar 5WAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=HzH07+hQ2f9XWnrNN4okuvmM0AVlC28DTm+0g0JVdKs=; b=xCinDQpuSxMbKJ88pTt/ytpm1UyVkJbkfVQZLVnCzzhxxnAM2S8CzMDMyXOANe+jc5 CfJyeTB94Cob43n73OUihNft3vZvM4MFe6uKhQWg/yXfCcUpiY8ip3G414q1rQsghRAy yQRg1ZL6FkVs+Tulz0X3bzOrZdhCI5XDU3a+wEOIjAtm/sJRbnpn/WeKvoZ+cWfPRpEP 4dbqdCShPo6dQNmyBbMY1XAQfY0sCH0MPlhlr68aW8BWNTtpVDOLH/K50vLty25ss1xy mIgzxSy9zbEjv8SVB6AF9pdga/Vo2oUGJrGLhAWBulGS0wPbinP3dBN1i4RsL8VasVei KV+Q== X-Gm-Message-State: AO0yUKVxa2BPuaGivBiXeuObNxo4ynACXKTCtOUpBd01F4aYI9YSpgAs E3rQanc5E9kS41G+fBTpf4AKX5AdbSA= X-Google-Smtp-Source: AK7set/o6UEjzD7XJ1L/XW2JkCvTcaI6KbzEhb1GW1FWpeKGXgsD2jDivS8Dfz48f9Y5DwROhZ25nQ== X-Received: by 2002:aa7:db56:0:b0:4ad:a70c:e010 with SMTP id n22-20020aa7db56000000b004ada70ce010mr13527525edt.41.1677176978085; Thu, 23 Feb 2023 10:29:38 -0800 (PST) Received: from localhost (dslb-188-109-240-043.188.109.pools.vodafone-ip.de. [188.109.240.43]) by smtp.gmail.com with ESMTPSA id v1-20020a50c401000000b004af733251cfsm76636edf.32.2023.02.23.10.29.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 10:29:37 -0800 (PST) Date: Thu, 23 Feb 2023 19:29:36 +0100 From: Daniel Tameling To: questions@freebsd.org Subject: Re: Cursing the tput utility - the penguin strikes again Message-ID: References: <974a81c2-a92d-7f94-5f96-869bddfe21f3@fjl.co.uk> 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 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <974a81c2-a92d-7f94-5f96-869bddfe21f3@fjl.co.uk> X-Spamd-Result: default: False [-3.99 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-0.999]; NEURAL_HAM_LONG(-0.99)[-0.993]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; MIME_GOOD(-0.10)[text/plain]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[questions@freebsd.org]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::52f:from]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_NONE(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; RCVD_TLS_LAST(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; MIME_TRACE(0.00)[0:+]; MLMMJ_DEST(0.00)[questions@freebsd.org] X-Rspamd-Queue-Id: 4PN1lR3jnjz3vJ3 X-Spamd-Bar: --- X-ThisMailContainsUnwantedMimeParts: N On Thu, Feb 23, 2023 at 04:45:21PM +0000, Frank Leonhardt wrote: > 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. > > > Did you try using the tput from devel/ncurses instead? I once ran into a similar problem and if I remember correctly that one works with the same options as on Linux because it's the one installed there. And it is frequently already installed as a dependency; the problem is just that the FreeBSD tput is earlier in PATH. -- Kind regards, Daniel