Skip to content
Snippets Groups Projects
Commit c9c7075d authored by Pierre Riteau's avatar Pierre Riteau
Browse files

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.
parent e60ea7bd
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment