]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-search.c
notmuch search: Fix missing final newline in "notmuch search --output=tags"
[notmuch] / notmuch-search.c
index 5907c2ee23d2f12ea9649c66d423bcba79b4699a..c628b369b66fadd975821261b4169e91c78ac3ca 100644 (file)
@@ -189,7 +189,9 @@ do_search_threads (const void *ctx,
     {
        int first_tag = 1;
 
-       if (! first_thread)
+       if (first_thread)
+           fputs (format->results_start, stdout);
+       else
            fputs (format->item_sep, stdout);
 
        thread = notmuch_threads_get (threads);
@@ -235,6 +237,9 @@ do_search_threads (const void *ctx,
        notmuch_thread_destroy (thread);
     }
 
+    if (! first_thread)
+       fputs (format->results_end, stdout);
+
     return 0;
 }
 
@@ -258,7 +263,9 @@ do_search_messages (const void *ctx,
     {
        message = notmuch_messages_get (messages);
 
-       if (! first_message)
+       if (first_message)
+           fputs (format->results_start, stdout);
+       else
            fputs (format->item_sep, stdout);
 
        if (output == OUTPUT_FILES) {
@@ -276,6 +283,9 @@ do_search_messages (const void *ctx,
 
     notmuch_messages_destroy (messages);
 
+    if (! first_message)
+       fputs (format->results_end, stdout);
+
     return 0;
 }
 
@@ -309,7 +319,9 @@ do_search_tags (const void *ctx,
     {
        tag = notmuch_tags_get (tags);
 
-       if (! first_tag)
+       if (first_tag)
+           fputs (format->results_start, stdout);
+       else
            fputs (format->item_sep, stdout);
 
        format->item_id (ctx, "", tag);
@@ -322,6 +334,9 @@ do_search_tags (const void *ctx,
     if (messages)
        notmuch_messages_destroy (messages);
 
+    if (! first_tag)
+       fputs (format->results_end, stdout);
+
     return 0;
 }
 
@@ -415,8 +430,6 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
 
     notmuch_query_set_sort (query, sort);
 
-    fputs (format->results_start, stdout);
-
     switch (output) {
     default:
     case OUTPUT_SUMMARY:
@@ -432,8 +445,6 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
        break;
     }
 
-    fputs (format->results_end, stdout);
-
     notmuch_query_destroy (query);
     notmuch_database_close (notmuch);