fix(cli): exit code
This commit is contained in:
parent
d4dfc554f0
commit
25116a7787
3 changed files with 8 additions and 8 deletions
|
|
@ -88,9 +88,9 @@ handle_one_option(int opt, char **argv, void *config,
|
|||
|
||||
SET_FLAG(*opt_tracker, (1ULL << bitmask_index));
|
||||
res = desc->handler(optarg, config);
|
||||
if (CLI_SUCCESS != res)
|
||||
if (CLI_ERROR == res)
|
||||
return error_invalid_opt(current_opt);
|
||||
return CLI_SUCCESS;
|
||||
return res;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ cli_parse_arguments(int argc, char **argv, struct ping_config *config)
|
|||
init_config(config);
|
||||
ret = cli_parse(argc, argv, config, g_options, PING_OPT_LEN,
|
||||
opt_str, long_opts);
|
||||
if (CLI_ERROR == ret)
|
||||
if (CLI_SUCCESS != ret)
|
||||
return ret;
|
||||
return cli_parse_destinations(argc, argv, optind, config);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cli.h"
|
||||
#include "ping/cli.h"
|
||||
#include "ping/ping.h"
|
||||
#include "version_gen.h"
|
||||
|
||||
/* Forward declarations */
|
||||
|
|
@ -14,11 +14,11 @@ struct prog_name g_prog_name = {NULL, NULL};
|
|||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct ping_config config;
|
||||
int ret;
|
||||
struct ping_config config = {0};
|
||||
int ret = CLI_ERROR;
|
||||
|
||||
if (0 != init_prog_name(argv[0]))
|
||||
return EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
ret = cli_parse_arguments(argc, argv, &config);
|
||||
if (ret != CLI_SUCCESS)
|
||||
goto cleanup;
|
||||
|
|
@ -28,7 +28,7 @@ main(int argc, char **argv)
|
|||
cleanup:
|
||||
cli_config_free(&config);
|
||||
free(g_prog_name.alloc);
|
||||
return (ret == CLI_ERROR) ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
return (ret == CLI_ERROR) ? 2 : EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue