Skip to content

Commit

Permalink
Command line arguments '--version' and '--help' return exit code 0 in…
Browse files Browse the repository at this point in the history
…stead of 255

Allows to detect whether those commands executed successfully, which makes integration with shell scripts/CI/bindings straightforward.

(cherry picked from commit e3a8edf)
  • Loading branch information
Bromeon authored and akien-mga committed Jun 30, 2022
1 parent 381e8dd commit 9e165a8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
packed_data->add_pack_source(zip_packed_data);
#endif

// Default exit code, can be modified for certain errors.
Error exit_code = ERR_INVALID_PARAMETER;

I = args.front();
while (I) {
#ifdef OSX_ENABLED
Expand All @@ -494,10 +497,12 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
if (I->get() == "-h" || I->get() == "--help" || I->get() == "/?") { // display help

show_help = true;
exit_code = OK;
goto error;

} else if (I->get() == "--version") {
print_line(get_full_version_string());
exit_code = OK;
goto error;

} else if (I->get() == "-v" || I->get() == "--verbose") { // verbose output
Expand Down Expand Up @@ -1328,7 +1333,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->finalize_core();
locale = String();

return ERR_INVALID_PARAMETER;
return exit_code;
}

Error Main::setup2(Thread::ID p_main_tid_override) {
Expand Down

0 comments on commit 9e165a8

Please sign in to comment.