def execute(command, ignore_failure = false)
debug( "Executing: #{command}" )
out_pipe_r, out_pipe_w = IO.pipe
err_pipe_r, err_pipe_w = IO.pipe
pid = spawn(command, :out => out_pipe_w, :err => err_pipe_w)
out_pipe_w.close
err_pipe_w.close
Process.wait(pid)
exitstatus = $?.nil? ? nil : $?.exitstatus
stdout = out_pipe_r.read
out_pipe_r.close
stderr = err_pipe_r.read
err_pipe_r.close
return true if ignore_failure
if exitstatus == 0
return true
else
error( "\n[#{command}] failed with exit status #{exitstatus}:", [:RED] )
stderr.split("\n").each do |line|
error( ' '*2 + line, [:RED] )
end
return false
end
end