Commit 6eed7f54 authored by Samuel E. Giddins's avatar Samuel E. Giddins

[Executable] Ensure the retval has the correct line endings

parent c7145ba6
...@@ -64,7 +64,7 @@ module Pod ...@@ -64,7 +64,7 @@ module Pod
end end
status = popen3(bin, command, stdout, stderr) status = popen3(bin, command, stdout, stderr)
output = stdout.join("\n") + stderr.join("\n") output = stdout.join + stderr.join
unless status.success? unless status.success?
if raise_on_failure if raise_on_failure
raise Informative, "#{full_command}\n\n#{output}" raise Informative, "#{full_command}\n\n#{output}"
...@@ -80,8 +80,8 @@ module Pod ...@@ -80,8 +80,8 @@ module Pod
def self.popen3(bin, command, stdout, stderr) def self.popen3(bin, command, stdout, stderr)
require 'open3' require 'open3'
Open3.popen3(bin, *command) do |i, o, e, t| Open3.popen3(bin, *command) do |i, o, e, t|
read(o, stdout) reader(o, stdout)
read(e, stderr) reader(e, stderr)
i.close i.close
status = t.value status = t.value
...@@ -94,20 +94,20 @@ module Pod ...@@ -94,20 +94,20 @@ module Pod
end end
end end
def self.read(input, output) def self.reader(input, output)
Thread.new do Thread.new do
buf = '' buf = ''
begin begin
loop do loop do
buf << input.readpartial(4096) buf << input.readpartial(4096)
loop do loop do
string, separator, buf = buf.partition(/[\n\r]/) string, separator, buf = buf.partition(/[\r\n]/)
break if separator.empty? break if separator.empty?
output << (string << separator) output << [string, separator]
end end
end end
rescue EOFError rescue EOFError
output << (buf << "\n") unless buf.size == 0 output << buf unless buf.size == 0
end end
end end
end end
...@@ -142,8 +142,11 @@ module Pod ...@@ -142,8 +142,11 @@ module Pod
# #
# @return [void] # @return [void]
# #
def <<(value) def <<(obj)
super value, newline = Array(obj)
newline ||= "\n"
value = value + newline
super(value)
ensure ensure
@io << "#{ indent }#{ value }" if @io @io << "#{ indent }#{ value }" if @io
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment