When using emerge in tmux since the introduction of "merge wait" status component since Portage release 3.0.66 with a terminal width of 80 columns, the terminal is flooded with incomplete status lines. This happens because the status line is by default too wide to enter in a 80 columns, however this does not happen every time. I noticed in the source code, file `lib/_emerge/JobStatusDisplay.py`, it should “Truncate to fit width, to avoid making the terminal scroll if the line overflows”. I made some test, with and without tmux, with direct invocation of Python (I replaced `self.out` by `sys.stdout`, see @property out of class `JobStatusDisplay`) ``` # Without tmux % python3 -c 'import os, sys; print(os.environ.get("TERM") != "dumb" and hasattr(sys.stdout, "isatty") and sys.stdout.isatty(), file=sys.stderr)' True % python3 -c 'import curses, os, sys; curses.setupterm(term=os.environ.get("TERM", "unknown"), fd=sys.stdout.fileno()); print(curses.tigetnum("lines"), curses.tigetnum("cols"), file=sys.stderr);' 24 80 # With tmux % python3 -c 'import os, sys; print(os.environ.get("TERM") != "dumb" and hasattr(sys.stdout, "isatty") and sys.stdout.isatty(), file=sys.stderr)' True % python3 -c 'import curses, os, sys; curses.setupterm(term=os.environ.get("TERM", "unknown"), fd=sys.stdout.fileno()); print(curses.tigetnum("lines"), curses.tigetnum("cols"), file=sys.stderr);' 23 80 # 23 instead of 24 because of Tmux’s own status line. ``` In commit a28a0fd6600242a2e062a0fd2d7d5be95296b7ae (and tweaks in 9f919c387fbc4c8526535b03fb781ab2a01ddfdd and 225e574108549ac85dd743bfbc0c3d5e2e740c60), the default value was raised to 100 from 80, while also reporting in its message the function “self._isatty has the tendency to return false, even though portage is actually run within a tty”. Reproducible: Sometimes Steps to Reproduce: 1. run emerge, such as `emerge -vatuD @world` 2. see line status too wide, flooding terminal.
I think this ticket can be closed, I didn’t understand the width of the terminal is queried at start, not during. And by usage, I used to resize the terminal width before and/or during so I can better read its output. Hence why I see sporadicly this issue. Unless emerge supports resize during execution, this is the correct behaviour, no actual bug is present. I let you decide if you prefer to close as-is the ticket or to implement dynamic width. Until then, sorry for the noise.
We certainly could handle SIGWINCH in order to adjust to terminal size changes dynamically.
Renaming mainly to remove tmux mention.
In https://github.com/gentoo/portage/pull/1402 I had to disable curses usage since it returned a stale width after terminal resize.