From 3df4ba1544e90f7dc7f01b018e92d018295b73c9 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Mon, 6 Jan 2020 17:25:25 +0100 Subject: [PATCH] Assume infinite terminal width when not running in a terminal Close https://github.com/docker/compose/issues/7119 Signed-off-by: Nicolas De Loof --- compose/cli/formatter.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compose/cli/formatter.py b/compose/cli/formatter.py index c1f43ed7a..9651fb4da 100644 --- a/compose/cli/formatter.py +++ b/compose/cli/formatter.py @@ -17,7 +17,12 @@ else: def get_tty_width(): try: - width, _ = get_terminal_size() + # get_terminal_size can't determine the size if compose is piped + # to another command. But in such case it doesn't make sense to + # try format the output by terminal size as this output is consumed + # by another command. So let's pretend we have a huge terminal so + # output is single-lined + width, _ = get_terminal_size(fallback=(999, 0)) return int(width) except OSError: return 0