summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKerin Millar <kfm@plushkava.net>2023-06-11 09:57:47 +0100
committerKerin Millar <kfm@plushkava.net>2023-06-11 10:18:32 +0100
commit6f6440c538efb2edbcdfe298521252b6510a1a80 (patch)
treee940047770a206f3dfa3b4c76855868f9c8f7a3f
parentecma48-cpr: Ignore SIGINT, SIGTERM and SIGTSTP (diff)
downloadgentoo-functions-6f6440c538efb2edbcdfe298521252b6510a1a80.tar.gz
gentoo-functions-6f6440c538efb2edbcdfe298521252b6510a1a80.tar.bz2
gentoo-functions-6f6440c538efb2edbcdfe298521252b6510a1a80.zip
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 <kfm@plushkava.net> Reported-by: Sam James <sam@gentoo.org>
-rw-r--r--functions.sh.in2
1 files changed, 1 insertions, 1 deletions
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