unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] Error out if no query is supplied to search instead of going into an infinite loop
@ 2009-11-18  0:23 Alex Botero-Lowry
  2009-11-18 11:31 ` Carl Worth
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Botero-Lowry @ 2009-11-18  0:23 UTC (permalink / raw)
  To: notmuch


[-- Attachment #1.1: Type: text/plain, Size: 1290 bytes --]

In this case error out when no query is supplied. There seems to be an
infinite-loop casued by i think notmuch_query_search_threads having
an exception:

A Xapian exception occurred: Syntax: <expression> AND <expression>
A Xapian exception occurred: Syntax: <expression> AND <expression>
A Xapian exception occurred: Syntax: <expression> AND <expression>
A Xapian exception occurred: Syntax: <expression> AND <expression>
A Xapian exception occurred: Syntax: <expression> AND <expression>
A Xapian exception occurred: Syntax: <expression> AND <expression>
A Xapian exception occurred: Syntax: <expression> AND <expression>
A Xapian exception occurred: Syntax: <expression> AND <expression>
A Xapian exception occurred: Syntax: <expression> AND <expression>
A Xapian exception occurred: Syntax: <expression> AND <expression>
A Xapian exception occurred: Syntax: <expression> AND <expression>
A Xapian exception occurred: Syntax: <expression> AND <expression>
A Xapian exception occurred: Syntax: <expression> AND <expression>
A Xapian exception occurred: Syntax: <expression> AND <expression>
A Xapian exception occurred: Syntax: <expression> AND <expression>

I'll look into that bug specifically a bit later.

It might be better to do a usage instead of just throwing an error here?

alex

[-- Attachment #1.2: Type: text/html, Size: 1553 bytes --]

[-- Attachment #2: 0001-Error-out-if-no-query-is-supplied-to-search-instead-.patch --]
[-- Type: application/octet-stream, Size: 794 bytes --]

From 3f9431f74a5ff66c84c869a3e26c2bad42bed1b1 Mon Sep 17 00:00:00 2001
From: Alexander Botero-Lowry <alex.boterolowry@gmail.com>
Date: Tue, 17 Nov 2009 16:20:28 -0800
Subject: [PATCH] Error out if no query is supplied to search instead of going into an infinite loop

---
 notmuch-search.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/notmuch-search.c b/notmuch-search.c
index 8db09c7..d94fccd 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -66,6 +66,11 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
     argc -= i;
     argv += i;
 
+    if (argc == 0) {
+        fprintf (stderr, "No query provided\n");
+        return 1;
+    }
+
     config = notmuch_config_open (ctx, NULL, NULL);
     if (config == NULL)
 	return 1;
-- 
1.6.5.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Error out if no query is supplied to search instead of going into an infinite loop
  2009-11-18  0:23 [PATCH] Error out if no query is supplied to search instead of going into an infinite loop Alex Botero-Lowry
@ 2009-11-18 11:31 ` Carl Worth
  0 siblings, 0 replies; 2+ messages in thread
From: Carl Worth @ 2009-11-18 11:31 UTC (permalink / raw)
  To: Alex Botero-Lowry, notmuch

On Tue, 17 Nov 2009 16:23:53 -0800, Alex Botero-Lowry <alex.boterolowry@gmail.com> wrote:
> In this case error out when no query is supplied. There seems to be an
> infinite-loop casued by i think notmuch_query_search_threads having
> an exception:
> A Xapian exception occurred: Syntax: <expression> AND <expression>
> A Xapian exception occurred: Syntax: <expression> AND <expression>
> A Xapian exception occurred: Syntax: <expression> AND <expression>
> 
> I'll look into that bug specifically a bit later.
> 
> It might be better to do a usage instead of just throwing an error here?

Definitely.

Priit Laes reported the same thing in IRC and I've just committed a
patch to give a nice error message:

$ ./notmuch search
Error: notmuch search requires at least one search term.

Thanks for the report!

-Carl

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-11-18 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-18  0:23 [PATCH] Error out if no query is supplied to search instead of going into an infinite loop Alex Botero-Lowry
2009-11-18 11:31 ` Carl Worth

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).