From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 637BC15812E for ; Sun, 11 Jun 2023 16:47:19 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A7BACE0899; Sun, 11 Jun 2023 16:47:18 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3FE3DE0899 for ; Sun, 11 Jun 2023 16:47:18 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 824863413DE for ; Sun, 11 Jun 2023 16:47:17 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id BCF3BA93 for ; Sun, 11 Jun 2023 16:47:14 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1686475112.6f6440c538efb2edbcdfe298521252b6510a1a80.sam@gentoo> Subject: [gentoo-commits] proj/gentoo-functions:master commit in: / X-VCS-Repository: proj/gentoo-functions X-VCS-Files: functions.sh.in X-VCS-Directories: / X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 6f6440c538efb2edbcdfe298521252b6510a1a80 X-VCS-Branch: master Date: Sun, 11 Jun 2023 16:47:14 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: e16a8a77-d791-4287-b302-bf051e512a13 X-Archives-Hash: c4283bbc8de06e838d5211a92db8750a commit: 6f6440c538efb2edbcdfe298521252b6510a1a80 Author: Kerin Millar plushkava net> AuthorDate: Sun Jun 11 08:57:47 2023 +0000 Commit: Sam James gentoo org> CommitDate: Sun Jun 11 09:18:32 2023 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=6f6440c5 Detect PTYs that aren't sufficiently functional to be considered as smart In this case, the offender is the PTY that is set up by the _create_pty_or_pipe() utility function in portage, which uses python's pty module. I transpires that its behaviour is not exactly equivalent to whichever controlling terminal is in effect at the time that emerge(1) is executed, if any. As a consequence, the ecma48-cpr utility times out while waiting for a response to the CPR (ECMA-48 CSI) sequence. I can discern no option other than to refrain from considering the terminal as being "smart" in this case. This is accomplished by recognising that stty(1) reports "0 0" when asked to check its size. These are nonsensical readings that would never be produced for a properly functioning, non-dumb terminal. In fact, this check used to be in place but was removed, simply because I forgot how important it is. Processes running under portage that call into gentoo-functions will still be able to produce coloured messages, but all the advantages of the smart terminal handling path will be obviated. This is unfortunate, but I have no intention of returning to the original, broken behaviour of gentoo-functions, which was to assume that the characteristics of the terminal found at the time of sourcing hold forever, and that STDOUT and STDERR will never refer to anything other than that same terminal. I would add that script(1) does not exhibit the same issue. $ tty /dev/pts/0 $ script -c 'tty; stty size <&1; /lib/gentoo/ecma48-cpr <&1' /dev/null Script started, output log file is '/dev/null'. /dev/pts/11 34 144 34 1 Script done. In other words, it is portage that is broken and which should be fixed. Signed-off-by: Kerin Millar plushkava.net> Reported-by: Sam James gentoo.org> functions.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.sh.in b/functions.sh.in index 9be9978..6f1ee75 100644 --- a/functions.sh.in +++ b/functions.sh.in @@ -626,7 +626,7 @@ _update_winsize() { # it may eventually become possible to support it. # shellcheck disable=2046 set -- $(stty size 2>/dev/null) - if [ "$#" -eq 2 ] && is_int "$1" && is_int "$2"; then + if [ "$#" -eq 2 ] && is_int "$1" && is_int "$2" && [ "$1" -gt 0 ] && [ "$2" -gt 0 ]; then genfun_rows=$1 genfun_cols=$2 else