From c7453773064efbd0b2cd17b15ba483edbd28ce1e Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Fri, 10 Jan 2014 23:28:53 +0200 Subject: cli: clean up exit status code returned by the cli commands Apart from the status codes for format mismatches, the non-zero exit status codes have been arbitrary. Make the cli consistently return either EXIT_SUCCESS or EXIT_FAILURE. --- notmuch-count.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'notmuch-count.c') diff --git a/notmuch-count.c b/notmuch-count.c index 01e4e301..6058f7c9 100644 --- a/notmuch-count.c +++ b/notmuch-count.c @@ -150,10 +150,8 @@ notmuch_count_command (notmuch_config_t *config, int argc, char *argv[]) }; opt_index = parse_arguments (argc, argv, options, 1); - - if (opt_index < 0) { - return 1; - } + if (opt_index < 0) + return EXIT_FAILURE; if (input_file_name) { batch = TRUE; @@ -161,23 +159,23 @@ notmuch_count_command (notmuch_config_t *config, int argc, char *argv[]) if (input == NULL) { fprintf (stderr, "Error opening %s for reading: %s\n", input_file_name, strerror (errno)); - return 1; + return EXIT_FAILURE; } } if (batch && opt_index != argc) { fprintf (stderr, "--batch and query string are not compatible\n"); - return 1; + return EXIT_FAILURE; } if (notmuch_database_open (notmuch_config_get_database_path (config), NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much)) - return 1; + return EXIT_FAILURE; query_str = query_string_from_args (config, argc-opt_index, argv+opt_index); if (query_str == NULL) { fprintf (stderr, "Out of memory.\n"); - return 1; + return EXIT_FAILURE; } if (exclude == EXCLUDE_TRUE) { @@ -197,5 +195,5 @@ notmuch_count_command (notmuch_config_t *config, int argc, char *argv[]) if (input != stdin) fclose (input); - return ret; + return ret ? EXIT_FAILURE : EXIT_SUCCESS; } -- cgit v1.2.3