From d1355af66ed9452a7ebd4b8bdd20f19359f3f1f2 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Sat, 16 Jan 2010 13:12:38 +0000 Subject: Check for bad values of console_width Fixes Homebrew/homebrew#453.--- Library/Homebrew/utils.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index f8965d090..79f739826 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -123,7 +123,8 @@ def puts_columns items, cols = 4 items.concat("\n") unless items.empty? # determine the best width to display for different console sizes - console_width = `/bin/stty size`.chomp.split(" ").last + console_width = `/bin/stty size`.chomp.split(" ").last.to_i + console_width = 80 if console_width <= 0 longest = items.sort_by { |item| item.length }.last optimal_col_width = (console_width.to_f / (longest.length + 2).to_f).floor cols = optimal_col_width > 1 ? optimal_col_width : 1 -- cgit v1.2.3