From ae8913bfd92ad4eaaa7bfcf2b2819277568faa59 Mon Sep 17 00:00:00 2001 From: Ben Winston Date: Thu, 23 May 2024 21:39:28 -0400 Subject: only write to temp file when asking to edit --- booki.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/booki.c b/booki.c index a2a6084..a1215ec 100644 --- a/booki.c +++ b/booki.c @@ -493,7 +493,7 @@ char** search(int argc, char* argv[], char* booki_file) { char* field; int i; - bool print = true; + bool match = true; for (i = 0; i < search_opts.count; i++) { field = search_opts.opts[i]; @@ -525,11 +525,13 @@ char** search(int argc, char* argv[], char* booki_file) { break; } } - print = i == search_opts.count; + match = i == search_opts.count; - if (print) { - print_book(*book, search_opts.show); - write_book(*book, output); + if (match) { + if (search_opts.edit) + write_book(*book, output); + else + print_book(*book, search_opts.show); book_count++; } } -- cgit v1.2.3