Skip to content

Commit

Permalink
Use termios instead of stty for compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
dago committed Feb 6, 2015
1 parent 23a2e52 commit 8471815
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bin/ansible-doc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import re
import optparse
import datetime
import subprocess
import fcntl
import termios
import struct

from ansible import utils
from ansible.utils import module_docs
import ansible.constants as C
Expand Down Expand Up @@ -167,7 +171,8 @@ def get_snippet_text(doc):
def get_module_list_text(module_list):
tty_size = 0
if os.isatty(0):
tty_size = int(os.popen('stty size', 'r').read().split()[1])
tty_size = struct.unpack('HHHH',
fcntl.ioctl(0, termios.TIOCGWINSZ, struct.pack('HHHH', 0, 0, 0, 0)))[1]
columns = max(60, tty_size)
displace = max(len(x) for x in module_list)
linelimit = columns - displace - 5
Expand Down

0 comments on commit 8471815

Please sign in to comment.