1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-14 10:13:05 +02:00

Remove exit() calls from main() to make it cleaner and more testable.

This commit is contained in:
David Steele 2018-02-18 15:45:32 -05:00
parent 599e41a251
commit f981283b8d

View File

@ -17,6 +17,8 @@ Main
int
main(int argListSize, const char *argList[])
{
bool error = false;
TRY_BEGIN()
{
// Load the configuration
@ -28,36 +30,36 @@ main(int argListSize, const char *argList[])
if (cfgCommandHelp())
{
cmdHelp();
exit(0);
}
// Display version
// -------------------------------------------------------------------------------------------------------------------------
if (cfgCommand() == cfgCmdVersion)
else if (cfgCommand() == cfgCmdVersion)
{
printf(PGBACKREST_NAME " " PGBACKREST_VERSION "\n");
fflush(stdout);
exit(0);
}
// Archive push command. Currently only implements local operations of async archive push.
// -------------------------------------------------------------------------------------------------------------------------
if (cfgCommand() == cfgCmdArchivePush && cfgOptionBool(cfgOptArchiveAsync))
else if (cfgCommand() == cfgCmdArchivePush && cfgOptionBool(cfgOptArchiveAsync))
{
cmdBegin();
cmdArchivePush();
exit(exitSafe(false));
}
// Execute Perl for commands not implemented in C
// -------------------------------------------------------------------------------------------------------------------------
perlExec();
else
{
perlExec();
}
}
CATCH_ANY()
{
exit(exitSafe(true));
error = true;
}
TRY_END();
exit(exitSafe(false));
return exitSafe(error);
}