Browse Source

Merge pull request #7122 from ndeloof/shutil

Don't adjust output on terminal width when piped into another command
Ulysses Souza 6 years ago
parent
commit
704ee56553
1 changed files with 6 additions and 1 deletions
  1. 6 1
      compose/cli/formatter.py

+ 6 - 1
compose/cli/formatter.py

@@ -17,7 +17,12 @@ else:
 
 
 def get_tty_width():
 def get_tty_width():
     try:
     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)
         return int(width)
     except OSError:
     except OSError:
         return 0
         return 0