From a2d2cf6b3120205e7916b8fc7370127409d7f306 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Thu, 18 Jul 2024 16:45:18 +0200 Subject: just-mr: Fix wrong exit code for --help call Due to the specifics of how CLI11 library handles the --help argument and the fact that just-mr uses its own set of exit codes, we were correctly printing the help text, but falsely returning a non-zero exit code as result. This is now fixed. (cherry-picked form faa8fc156ed8314db23a2d1612975ee745a50ade) --- src/other_tools/just_mr/main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp index 31f63d3d..d27cb3a5 100644 --- a/src/other_tools/just_mr/main.cpp +++ b/src/other_tools/just_mr/main.cpp @@ -132,8 +132,11 @@ void SetupSetupCommandArguments( try { app.parse(argc, argv); } catch (CLI::Error& e) { - [[maybe_unused]] auto err = app.exit(e); - std::exit(kExitClargsError); + // CLI11 throws for things like --help calls for them to be handled + // separately by parse callers. In this case it nevertheless sets the + // error code to 0 (success). + auto const err = app.exit(e); + std::exit(err == 0 ? kExitSuccess : kExitClargsError); } catch (std::exception const& ex) { Logger::Log(LogLevel::Error, "Command line parse error: {}", ex.what()); std::exit(kExitClargsError); -- cgit v1.2.3