notmuch search: Avoid infinite stream of exceptions from "notmuch search"

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.
This commit is contained in:
Carl Worth 2009-11-18 03:29:30 -08:00
parent 26a4741b9c
commit 306635c27d

View file

@ -138,6 +138,10 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
fprintf (stderr, "Out of memory.\n"); fprintf (stderr, "Out of memory.\n");
return 1; 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); query = notmuch_query_create (notmuch, query_str);
if (query == NULL) { if (query == NULL) {