summaryrefslogtreecommitdiffstats
path: root/pym/portage/output.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-12-10 11:13:28 -0800
committerZac Medico <zmedico@gentoo.org>2011-12-10 11:13:28 -0800
commit93c60fc277e37109a4ead36f69a6a50b7f72b229 (patch)
tree74846ab15e2211ed99cd5a715520fbebc21bfc5d /pym/portage/output.py
parentc37d0c55ac3f70586afcad86636973de35eabe4e (diff)
downloadportage-93c60fc277e37109a4ead36f69a6a50b7f72b229.tar.gz
portage-93c60fc277e37109a4ead36f69a6a50b7f72b229.tar.bz2
portage-93c60fc277e37109a4ead36f69a6a50b7f72b229.zip
get_term_size: all values >= 0 for bug #394091
Diffstat (limited to 'pym/portage/output.py')
-rw-r--r--pym/portage/output.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/pym/portage/output.py b/pym/portage/output.py
index 6b10f7b6c..43d75036e 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -422,12 +422,14 @@ class StyleWriter(formatter.DumbWriter):
def get_term_size():
"""
Get the number of lines and columns of the tty that is connected to
- stdout. Returns a tuple of (lines, columns) or (-1, -1) if an error
+ stdout. Returns a tuple of (lines, columns) or (0, 0) if an error
occurs. The curses module is used if available, otherwise the output of
- `stty size` is parsed.
+ `stty size` is parsed. The lines and columns values are guaranteed to be
+ greater than or equal to zero, since a negative COLUMNS variable is
+ known to prevent some commands from working (see bug #394091).
"""
if not sys.stdout.isatty():
- return -1, -1
+ return (0, 0)
try:
import curses
try:
@@ -442,10 +444,13 @@ def get_term_size():
out = out.split()
if len(out) == 2:
try:
- return int(out[0]), int(out[1])
+ val = (int(out[0]), int(out[1]))
except ValueError:
pass
- return -1, -1
+ else:
+ if val[0] >= 0 and val[1] >= 0:
+ return val
+ return (0, 0)
def set_term_size(lines, columns, fd):
"""