# HG changeset patch # User Matthew Wild # Date 1298407942 0 # Node ID b5d6e443e571d7d783704c1d5ccd7f4c09700d9d # Parent 36f5bf718d3c8c7f76062e91fe82fafebd611045 raw: If using --stdin and not --interactive then buffer all data before connecting, more reliable in a non-interactive environment diff -r 36f5bf718d3c -r b5d6e443e571 clix/raw.lua --- a/clix/raw.lua Tue Dec 14 20:18:56 2010 +0000 +++ b/clix/raw.lua Tue Feb 22 20:52:22 2011 +0000 @@ -6,9 +6,15 @@ print("Send/receive raw XML to/from the server"); return; end + + local send_xml; + if opts.stdin then + send_xml = io.read("*a"); + end + local function on_connect(conn) - conn:hook("incoming-raw", print); - if opts.interactive or opts.stdin then + conn:hook("incoming-raw", function (data) print(data) end); + if opts.interactive then local stdin = { getfd = function () return 0; end; dirty = function (self) return false; end; @@ -33,7 +39,11 @@ onincoming = on_incoming, ondisconnect = function () end }, "*l"); else - conn:send(table.concat(arg, " ")); + if send_xml then + conn:send(send_xml); + else + conn:send(table.concat(arg, " ")); + end conn:close(); end