From 272e700f509ddd968032940353de3f718be0912f Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 24 Apr 2024 11:45:37 +0100 Subject: prosodyctl shell: Fix invocation with 3+ command arguments The code correctly inserted the ',' when there was already a "%q" in the format string, but then the next argument would fail to match because it inserted ", %q" instead of "%q". The code now matches both, ensuring the generated code will not produce a syntax error with multiple arguments. --- util/prosodyctl/shell.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/prosodyctl/shell.lua b/util/prosodyctl/shell.lua index f3279e75..05f81f15 100644 --- a/util/prosodyctl/shell.lua +++ b/util/prosodyctl/shell.lua @@ -83,7 +83,7 @@ local function start(arg) --luacheck: ignore 212/arg for i = 3, #arg do if arg[i]:sub(1, 1) == ":" then table.insert(fmt, i, ")%s("); - elseif i > 3 and fmt[i - 1] == "%q" then + elseif i > 3 and fmt[i - 1]:match("%%q$") then table.insert(fmt, i, ", %q"); else table.insert(fmt, i, "%q"); -- cgit v1.2.3