Skip to content

Commit cfc4019

Browse files
authored
Merge pull request #2745 from MikeMcQuaid/tty-width
tty: handle non-tty stdin.
2 parents b2995be + 2cf2c02 commit cfc4019

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Library/Homebrew/utils/tty.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ def strip_ansi(string)
66
end
77

88
def width
9-
(`/bin/stty size`.split[1] || 80).to_i
9+
width = `/bin/stty size 2>/dev/null`.split[1]
10+
width ||= `/usr/bin/tput cols 2>/dev/null`.split[0]
11+
width ||= 80
12+
width.to_i
1013
end
1114

1215
def truncate(string)

0 commit comments

Comments
 (0)