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.
This commit is contained in:
parent
e60ea7bd20
commit
c9c7075dc1
@ -76,8 +76,13 @@ end
|
||||
|
||||
def puts_columns items, cols = 4
|
||||
items = items.join("\n") if items.is_a?(Array)
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user