util.prosodyctl.shell: Support for receiving partial lines (no automatic \n)
authorMatthew Wild <mwild1@gmail.com>
Thu, 17 Mar 2022 10:21:43 +0000
changeset 12400 bdb9577a4830
parent 12399 1e34b910b73a
child 12401 ddf02f2a3354
util.prosodyctl.shell: Support for receiving partial lines (no automatic \n)
util/prosodyctl/shell.lua
--- a/util/prosodyctl/shell.lua	Thu Mar 17 10:20:23 2022 +0000
+++ b/util/prosodyctl/shell.lua	Thu Mar 17 10:21:43 2022 +0000
@@ -89,11 +89,15 @@
 		local errors = 0; -- TODO This is weird, but works for now.
 		client.events.add_handler("received", function(stanza)
 			if stanza.name == "repl-output" or stanza.name == "repl-result" then
+				local dest = io.stdout;
 				if stanza.attr.type == "error" then
 					errors = errors + 1;
-					io.stderr:write(stanza:get_text(), "\n");
+					dest = io.stderr;
+				end
+				if stanza.attr.eol == "0" then
+					dest:write(stanza:get_text());
 				else
-					print(stanza:get_text());
+					dest:write(stanza:get_text(), "\n");
 				end
 			end
 			if stanza.name == "repl-result" then