aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2017-06-07 06:57:44 +0100
committerMike McQuaid2017-06-07 06:57:50 +0100
commit2cf2c020ba04f57ac9e77712df6a25525744715b (patch)
treef77b3fa5ddaa9a36a0a9e8bc7483fb3d274ac34a /Library
parentb2995be4453e8d2d7367dac1d573258f2a59148f (diff)
downloadbrew-2cf2c020ba04f57ac9e77712df6a25525744715b.tar.bz2
tty: handle non-tty stdin.
When stdin is not a tty then the message `stty: stdin isn't a terminal` will be produced. Silence this message and fall back to `tput` when it fails and default to 80 if we get no results at all. Follow-up from #2714.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/utils/tty.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/Library/Homebrew/utils/tty.rb b/Library/Homebrew/utils/tty.rb
index 642a33b91..e872e6460 100644
--- a/Library/Homebrew/utils/tty.rb
+++ b/Library/Homebrew/utils/tty.rb
@@ -6,7 +6,10 @@ module Tty
end
def width
- (`/bin/stty size`.split[1] || 80).to_i
+ width = `/bin/stty size 2>/dev/null`.split[1]
+ width ||= `/usr/bin/tput cols 2>/dev/null`.split[0]
+ width ||= 80
+ width.to_i
end
def truncate(string)