summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--litterbox.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/litterbox.h b/litterbox.h
index 48d707c..07d4bbc 100644
--- a/litterbox.h
+++ b/litterbox.h
@@ -48,15 +48,19 @@ static inline sqlite3 *dbOpen(int flags) {
 	const char *home = getenv("HOME");
 	const char *dataHome = getenv("XDG_DATA_HOME");
 	const char *dataDirs = getenv("XDG_DATA_DIRS");
+
 	char path[PATH_MAX];
 	if (dataHome) {
 		snprintf(path, sizeof(path), "%s/" DATABASE_PATH, dataHome);
 	} else {
+		if (!home) errx(EX_CONFIG, "HOME unset");
 		snprintf(path, sizeof(path), "%s/.local/share/" DATABASE_PATH, home);
 	}
 	sqlite3 *db = dbOpenPath(path, flags);
 	if (db) return db;
-	while (dataDirs && *dataDirs) {
+
+	if (!dataDirs) dataDirs = "/usr/local/share:/usr/share";
+	while (*dataDirs) {
 		size_t len = strcspn(dataDirs, ":");
 		snprintf(path, sizeof(path), "%.*s/" DATABASE_PATH, (int)len, dataDirs);
 		db = dbOpenPath(path, flags);
Enroe 2020-06-07Cast z_stream fields to size_tJune McEnroe 2020-06-07Call static_assert by _Static_assertJune McEnroe 2020-06-07Add OpenBSD to install.shJune McEnroe 2020-06-03Add The Song of AchillesJune McEnroe 2020-06-01Allow redirecting input in everJune McEnroe 2020-05-31Add %c conversion to c scriptJune McEnroe 2020-05-31Add c script to READMEJune McEnroe 2020-05-31Add c scriptJune McEnroe 2020-05-31Update mdoc source URLsJune McEnroe 2020-05-26Remove unfinished PSF fontsJune McEnroe