prosodyctl shell: More reliable detection of REPL/interactive mode (fixes #1895)

This commit is contained in:
Matthew Wild 2025-03-13 11:37:11 +00:00
parent 384e3dbea2
commit 57d168dd5e
2 changed files with 5 additions and 7 deletions

View file

@ -342,6 +342,8 @@ local function handle_line(event)
local line = event.stanza:get_text();
local useglobalenv;
session.repl = event.stanza.attr.repl ~= "0";
local result = st.stanza("repl-result");
if line:match("^>") then
@ -422,10 +424,6 @@ local function handle_line(event)
end
end
if not source then
session.repl = true;
end
taskok, message = chunk(flags);
if promise.is_promise(taskok) then

View file

@ -29,8 +29,8 @@ local function read_line(prompt_string)
end
end
local function send_line(client, line)
client.send(st.stanza("repl-input", { width = tostring(term_width()) }):text(line));
local function send_line(client, line, interactive)
client.send(st.stanza("repl-input", { width = tostring(term_width()), repl = interactive == false and "0" or "1" }):text(line));
end
local function repl(client)
@ -91,7 +91,7 @@ local function start(arg) --luacheck: ignore 212/arg
end
client.events.add_handler("connected", function()
send_line(client, arg[1]);
send_line(client, arg[1], false);
return true;
end, 1);