Fall back to system-wide epigram directory.
[tfortune.git] / tfortune.c
index 02e54ea40e864032e75886c454bb742b8b3c37c8..e3eef042fcd2b81bd4bb24a96243d28c5f66ed94 100644 (file)
@@ -302,9 +302,16 @@ static char *get_basedir(void)
 static char *get_epidir(void)
 {
        char *basedir, *epidir;
+       struct stat s;
+
        basedir = get_basedir();
        xasprintf(&epidir, "%s/epigrams", basedir);
        free(basedir);
+       if (!OPT_GIVEN(TFORTUNE, BASEDIR) && stat(epidir, &s) < 0) {
+               free(epidir);
+               epidir = xstrdup(DATADIR "/tfortunes/epigrams");
+               INFO_LOG("falling back to system-wide epidir %s\n", epidir);
+       }
        return epidir;
 }