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-search.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-search.c')
-rw-r--r-- | notmuch-search.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/notmuch-search.c b/notmuch-search.c index 7c973b3d..91b5d105 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -401,10 +401,8 @@ notmuch_search_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; switch (format_sel) { case NOTMUCH_FORMAT_TEXT: @@ -413,7 +411,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) case NOTMUCH_FORMAT_TEXT0: if (output == OUTPUT_SUMMARY) { fprintf (stderr, "Error: --format=text0 is not compatible with --output=summary.\n"); - return 1; + return EXIT_FAILURE; } format = sprinter_text0_create (config, stdout); break; @@ -432,22 +430,22 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) 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 (notmuch, argc-opt_index, argv+opt_index); if (query_str == NULL) { fprintf (stderr, "Out of memory.\n"); - return 1; + return EXIT_FAILURE; } if (*query_str == '\0') { fprintf (stderr, "Error: notmuch search requires at least one search term.\n"); - return 1; + return EXIT_FAILURE; } query = notmuch_query_create (notmuch, query_str); if (query == NULL) { fprintf (stderr, "Out of memory\n"); - return 1; + return EXIT_FAILURE; } notmuch_query_set_sort (query, sort); @@ -491,5 +489,5 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) talloc_free (format); - return ret; + return ret ? EXIT_FAILURE : EXIT_SUCCESS; } |