From 139dae9ae1e1d86cb24d313a4b38c980cb915f29 Mon Sep 17 00:00:00 2001 From: Ben Winston Date: Sun, 26 May 2024 21:04:58 -0400 Subject: use an environment variable for the file --- booki.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/booki.c b/booki.c index fc6468f..7a1e41d 100644 --- a/booki.c +++ b/booki.c @@ -7,7 +7,6 @@ #include #include -#define BOOKI_FILE_REL ".local/share/booki/books.toml" #define EDIT_FILE "tmp.toml" #define MAX_SEARCH_OPTS 5 @@ -555,9 +554,12 @@ void help(bool err) { int main(int argc, char* argv[]) { - char* home = getenv("HOME"); - char booki_file[strlen(home) + strlen(BOOKI_FILE_REL) + 1]; - sprintf(booki_file, "%s/%s", home, BOOKI_FILE_REL); + char* booki_file = getenv("BOOKI_FILE"); + if (!booki_file) { + printf("expecting BOOKI_FILE variable\n"); + return 1; + } + char** remaining = NULL; if (argc == 1) { -- cgit v1.2.3