[2.10] display: use stdout for column width (#70290)
stdout may differ from stdin so it should be used to determine the column
width, especially since it is the target file descriptor.
(cherry picked from commit 45e0f74702
)
Co-authored-by: Pavel Březina <pbrezina@redhat.com>
This commit is contained in:
parent
273159da4c
commit
3afa0424b3
2 changed files with 4 additions and 2 deletions
2
changelogs/fragments/display-stdout-column-width.yml
Normal file
2
changelogs/fragments/display-stdout-column-width.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- Ansible output now uses stdout to determine column width instead of stdin
|
|
@ -430,8 +430,8 @@ class Display(with_metaclass(Singleton, object)):
|
||||||
return encoding
|
return encoding
|
||||||
|
|
||||||
def _set_column_width(self):
|
def _set_column_width(self):
|
||||||
if os.isatty(0):
|
if os.isatty(1):
|
||||||
tty_size = unpack('HHHH', fcntl.ioctl(0, TIOCGWINSZ, pack('HHHH', 0, 0, 0, 0)))[1]
|
tty_size = unpack('HHHH', fcntl.ioctl(1, TIOCGWINSZ, pack('HHHH', 0, 0, 0, 0)))[1]
|
||||||
else:
|
else:
|
||||||
tty_size = 0
|
tty_size = 0
|
||||||
self.columns = max(79, tty_size - 1)
|
self.columns = max(79, tty_size - 1)
|
||||||
|
|
Loading…
Reference in a new issue