]> git.notmuchmail.org Git - notmuch/commitdiff
notmuch search: Avoid infinite stream of exceptions from "notmuch search"
authorCarl Worth <cworth@cworth.org>
Wed, 18 Nov 2009 11:29:30 +0000 (03:29 -0800)
committerCarl Worth <cworth@cworth.org>
Wed, 18 Nov 2009 11:29:30 +0000 (03:29 -0800)
That is, give a nice error message and exit if no search terms are
provided. Thanks to Priit Laes <plaes@plaes.org> for reporting the
error and providing an early version of the fix.

notmuch-search.c

index f7f9e70c041d746df56a6bc0386bc06358a67765..2b1c0fea950d01ae0c37e30accfc1256cd0c5f93 100644 (file)
@@ -138,6 +138,10 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
        fprintf (stderr, "Out of memory.\n");
        return 1;
     }
        fprintf (stderr, "Out of memory.\n");
        return 1;
     }
+    if (*query_str == '\0') {
+       fprintf (stderr, "Error: notmuch search requires at least one search term.\n");
+       return 1;
+    }
 
     query = notmuch_query_create (notmuch, query_str);
     if (query == NULL) {
 
     query = notmuch_query_create (notmuch, query_str);
     if (query == NULL) {