mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-03 09:29:38 +01:00
Ported: Fix exit code of --help and --version, and test them in CI
Corrects prior regression which caused ERROR output and exit code of 1. - Bromeon
861e155543
This commit is contained in:
parent
d10acf7390
commit
e7100658d4
@ -489,12 +489,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
|
if (I->get() == "-h" || I->get() == "--help" || I->get() == "/?") { // display help
|
||||||
|
|
||||||
show_help = true;
|
show_help = true;
|
||||||
exit_code = OK;
|
exit_code = ERR_HELP; // Hack to force an early exit in `main()` with a success code.
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
} else if (I->get() == "--version") {
|
} else if (I->get() == "--version") {
|
||||||
print_line(get_full_version_string());
|
print_line(get_full_version_string());
|
||||||
exit_code = OK;
|
exit_code = ERR_HELP; // Hack to force an early exit in `main()` with a success code.
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
} else if (I->get() == "-v" || I->get() == "--verbose") { // verbose output
|
} else if (I->get() == "-v" || I->get() == "--verbose") { // verbose output
|
||||||
|
@ -204,6 +204,7 @@ JNIEXPORT void JNICALL Java_net_relintai_pandemonium_pandemonium_PandemoniumLib_
|
|||||||
memfree(cmdline);
|
memfree(cmdline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: --help and --version return ERR_HELP, but this should be translated to 0 if exit codes are propagated.
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
return; // should exit instead and print the error
|
return; // should exit instead and print the error
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,10 @@ int iphone_main(int argc, char **argv, String data_dir, String cache_dir) {
|
|||||||
printf("os created\n");
|
printf("os created\n");
|
||||||
Error err = Main::setup(fargv[0], argc - 1, &fargv[1], false);
|
Error err = Main::setup(fargv[0], argc - 1, &fargv[1], false);
|
||||||
printf("setup %i\n", err);
|
printf("setup %i\n", err);
|
||||||
if (err != OK) {
|
|
||||||
|
if (err == ERR_HELP) { // Returned by --help and --version, so success.
|
||||||
|
return 0;
|
||||||
|
} else if (err != OK) {
|
||||||
return 255;
|
return 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,11 +64,15 @@ int main(int argc, char **argv) {
|
|||||||
err = Main::setup(argv[0], argc - first_arg, &argv[first_arg]);
|
err = Main::setup(argv[0], argc - first_arg, &argv[first_arg]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err != OK)
|
if (err == ERR_HELP) { // Returned by --help and --version, so success.
|
||||||
|
return 0;
|
||||||
|
} else if (err != OK) {
|
||||||
return 255;
|
return 255;
|
||||||
|
}
|
||||||
|
|
||||||
if (Main::start())
|
if (Main::start()) {
|
||||||
os.run(); // it is actually the OS that decides how to run
|
os.run(); // it is actually the OS that decides how to run
|
||||||
|
}
|
||||||
|
|
||||||
Main::cleanup();
|
Main::cleanup();
|
||||||
|
|
||||||
|
@ -162,6 +162,11 @@ __declspec(dllexport) int widechar_main(int argc, wchar_t **argv) {
|
|||||||
delete[] argv_utf8[i];
|
delete[] argv_utf8[i];
|
||||||
}
|
}
|
||||||
delete[] argv_utf8;
|
delete[] argv_utf8;
|
||||||
|
|
||||||
|
if (err == ERR_HELP) { // Returned by --help and --version, so success.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return 255;
|
return 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,11 @@ int main(int argc, char *argv[]) {
|
|||||||
Error err = Main::setup(argv[0], argc - 1, &argv[1]);
|
Error err = Main::setup(argv[0], argc - 1, &argv[1]);
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
free(cwd);
|
free(cwd);
|
||||||
|
|
||||||
|
if (err == ERR_HELP) { // Returned by --help and --version, so success.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return 255;
|
return 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user