aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Winston2024-05-23 21:39:28 -0400
committerBen Winston2024-05-23 21:39:28 -0400
commitae8913bfd92ad4eaaa7bfcf2b2819277568faa59 (patch)
treeff971af436f62d6f1b541609bd5dbdf32263dbad
parentdbe56773532d8adaf547af91899978990984e853 (diff)
only write to temp file when asking to edit
-rw-r--r--booki.c12
1 files 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++;
}
}