diff --git a/bin/ansible-doc b/bin/ansible-doc index 0ba84b9a305..59d14b6ef14 100755 --- a/bin/ansible-doc +++ b/bin/ansible-doc @@ -165,7 +165,10 @@ def get_snippet_text(doc): return "\n".join(text) def get_module_list_text(module_list): - columns = max(60, int(os.popen('stty size', 'r').read().split()[1])) + tty_size = 0 + if os.isatty(0): + tty_size = int(os.popen('stty size', 'r').read().split()[1]) + columns = max(60, tty_size) displace = max(len(x) for x in module_list) linelimit = columns - displace - 5 text = []