diff options
author | Jani Nikula <jani@nikula.org> | 2014-01-10 23:28:53 +0200 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2014-01-18 14:45:26 -0400 |
commit | c7453773064efbd0b2cd17b15ba483edbd28ce1e (patch) | |
tree | 00d526c4d671c4a793573fff423888d4b81beb05 /notmuch-reply.c | |
parent | 17e44cd584017c9187860e0dc80ea407940b8939 (diff) |
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.
Diffstat (limited to 'notmuch-reply.c')
-rw-r--r-- | notmuch-reply.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/notmuch-reply.c b/notmuch-reply.c index 9d6f8436..79cdc833 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -704,7 +704,7 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[]) notmuch_database_t *notmuch; notmuch_query_t *query; char *query_string; - int opt_index, ret = 0; + int opt_index; int (*reply_format_func) (void *ctx, notmuch_config_t *config, notmuch_query_t *query, @@ -739,10 +739,8 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[]) }; opt_index = parse_arguments (argc, argv, options, 1); - if (opt_index < 0) { - /* diagnostics already printed */ - return 1; - } + if (opt_index < 0) + return EXIT_FAILURE; if (format == FORMAT_HEADERS_ONLY) { reply_format_func = notmuch_reply_format_headers_only; @@ -761,30 +759,30 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[]) query_string = query_string_from_args (config, argc-opt_index, argv+opt_index); if (query_string == NULL) { fprintf (stderr, "Out of memory\n"); - return 1; + return EXIT_FAILURE; } if (*query_string == '\0') { fprintf (stderr, "Error: notmuch reply requires at least one search term.\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 = notmuch_query_create (notmuch, query_string); if (query == NULL) { fprintf (stderr, "Out of memory\n"); - return 1; + return EXIT_FAILURE; } if (reply_format_func (config, config, query, ¶ms, reply_all, sp) != 0) - return 1; + return EXIT_FAILURE; notmuch_crypto_cleanup (¶ms.crypto); notmuch_query_destroy (query); notmuch_database_destroy (notmuch); - return ret; + return EXIT_SUCCESS; } |