aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Riteau2009-09-22 20:43:06 +0200
committerPierre Riteau2009-09-22 20:43:06 +0200
commit7a7876d678735e12ac343b4c1e172ba6025290df (patch)
treebc8a600c8e4a9182ef42473fbf66f14e4c29516c
parentfeb69f8f5373c1b19d9ba74d7cbfa0bdce370f39 (diff)
downloadhomebrew-7a7876d678735e12ac343b4c1e172ba6025290df.tar.bz2
Don't print text as columns when the output is not a tty
The code also makes sure to terminate with a newline, unless the output is empty.
-rw-r--r--Library/Homebrew/utils.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 7658e35cb..3efeb99a6 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -76,8 +76,13 @@ end
def puts_columns items, cols = 4
items = items.join("\n") if items.is_a?(Array)
- width=`stty size`.chomp.split(" ").last
- IO.popen("pr -#{cols} -t", "w"){|io| io.write(items) }
+ items.concat("\n") unless items.empty?
+ if $stdout.tty?
+ width=`stty size`.chomp.split(" ").last
+ IO.popen("pr -#{cols} -t", "w"){|io| io.write(items) }
+ else
+ items.each { |i| $stdout.write(i) }
+ end
end
def exec_editor *args