Mercurial > prosody-hg
changeset 14016:1df1782ccdfe
prosodyctl shell: Improve process exit codes
This fixes a bug introduced in 3326c8a29a86 where prosodyctl shell would
always exit with non-zero error codes, even on success. Now it will exit with
0 for success, or 1 if any errors were printed.
It also updates the other exit codes in the shell command to help distinguish
between different error cases. These are based on the sysexits.h codes,
although it is not recommended to rely on that interface.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 19 Dec 2025 15:32:26 +0000 |
| parents | 42e035cd3322 |
| children | 1e01b91cf94d |
| files | util/prosodyctl/shell.lua |
| diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/util/prosodyctl/shell.lua Fri Dec 19 14:50:10 2025 +0000 +++ b/util/prosodyctl/shell.lua Fri Dec 19 15:32:26 2025 +0000 @@ -82,7 +82,7 @@ elseif err == "missing-value" then print("Expected a value to follow command-line option: "..where); end - os.exit(1); + os.exit(64); end if arg[1] then @@ -100,7 +100,9 @@ if stanza.name == "repl-output" or stanza.name == "repl-result" then local dest = io.stdout; if stanza.name == "repl-result" or stanza.attr.type == "error" then - errors = errors + 1; + if stanza.attr.type == "error" then + errors = errors + 1; + end dest = io.stderr; end if stanza.attr.eol == "0" then @@ -110,7 +112,7 @@ end end if stanza.name == "repl-result" then - os.exit(errors); + os.exit(errors > 0 and 1 or 0); end return true; end, 1); @@ -141,7 +143,7 @@ }):text(password or "")); else io.stderr:write("Internal error - unexpected input request type "..tostring(stanza.attr.type).."\n"); - os.exit(1); + os.exit(76); end return true; end, 2); @@ -174,7 +176,7 @@ print("** Unable to connect to server - is it running? Is mod_admin_shell enabled?"); print("** Connection error: "..err); end - os.exit(1); + os.exit(69); end server.loop(); end
