summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorJan Haller <bromeon@gmail.com>2022-06-30 13:55:15 +0200
committerJan Haller <bromeon@gmail.com>2022-06-30 13:55:15 +0200
commite3a8edf536ab8115594b0d6c3efa0603e71825ad (patch)
tree6b56cb1869b0478d3bd9d016c46b81d55b2c5589 /main
parentfd3970f7625c39aa22be94a0fa5396bd0eeb6f06 (diff)
Command line arguments '--version' and '--help' return exit code 0 instead of 255
Allows to detect whether those commands executed successfully, which makes integration with shell scripts/CI/bindings straightforward.
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/main/main.cpp b/main/main.cpp
index f3c56c7205..00b7483406 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -673,6 +673,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
@@ -688,10 +691,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
@@ -1636,7 +1641,7 @@ error:
OS::get_singleton()->finalize_core();
locale = String();
- return ERR_INVALID_PARAMETER;
+ return exit_code;
}
Error Main::setup2(Thread::ID p_main_tid_override) {