diff --git a/ChangeLog.md b/ChangeLog.md index 1c645b02..55fd6022 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -8,6 +8,7 @@ ## Features * add "-m" option to "encode" and "decode" commands +* add output for commands executed with "--inject=stop" # 24.1 (2024-10-27) diff --git a/src/ebusd/main.cpp b/src/ebusd/main.cpp index b5edc564..5b24a0fe 100644 --- a/src/ebusd/main.cpp +++ b/src/ebusd/main.cpp @@ -554,15 +554,20 @@ int main(int argc, char* argv[], char* envp[]) { if (arg.find_first_of(' ') != string::npos || arg.find_first_of('/') == string::npos) { RequestImpl req(false); req.add(argv[arg_index]); - bool connected; - RequestMode reqMode; + bool connected = true; + RequestMode reqMode = {}; string user; - bool reload; + bool reload = false; ostringstream ostream; result_t ret = s_mainLoop->decodeRequest(&req, &connected, &reqMode, &user, &reload, &ostream); - if (ret != RESULT_OK) { - string output = ostream.str(); - logError(lf_main, "executing command %s failed: %d", argv[arg_index], output.c_str()); + string output = ostream.str(); + if (ret != RESULT_OK || output.substr(0, 3) == "ERR" || output.substr(0, 5) == "usage") { + if (output.empty()) { + output = getResultCode(ret); + } + logError(lf_main, "executing command \"%s\" failed: %s", argv[arg_index], output.c_str()); + } else if (s_opt.stopAfterInject) { + logNotice(lf_main, "executed command \"%s\": %s", argv[arg_index], output.c_str()); } continue; }