aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorPierre Riteau2009-09-22 20:43:06 +0200
committerPierre Riteau2009-09-22 20:43:06 +0200
commitc9c7075dc116c4fc6813a1120c21339f7aebaf25 (patch)
treeb1659e9590f55d0de3f445371f661385d253361d /Library
parente60ea7bd2099873737c33c50bf65c2df908294b7 (diff)
downloadbrew-c9c7075dc116c4fc6813a1120c21339f7aebaf25.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.
Diffstat (limited to 'Library')
-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