If the per-user directory can not be opened, we currently print an
error message and exit. As pointed out by Adam Borowski, this is not
especially user-friendly.
This commit teaches tfortune to look in a second, system-wide location
in this case. This location can be controlled with the --datadir
option of configure. The man page is updated accordingly.
index.html tfortune.suite: %: %.m4
$(call SAY, M4 $<)
$(M4) -D "AUTHOR=$(AUTHOR)" -D "COPYRIGHT_YEAR=$(COPYRIGHT_YEAR)" \
+ -D "DATADIR=$(datadir)" \
-D "PACKAGE=$(PACKAGE)" \
-D "SLOGAN=$(SLOGAN)" \
-D "EMAIL=$(EMAIL)" \
TF_CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
TF_CPPFLAGS += -DLICENSE='"$(LICENSE)"'
TF_CPPFLAGS += -DLICENSE_URL='"$(LICENSE_URL)"'
+TF_CPPFLAGS += -DDATADIR='"$(datadir)"'
TF_CPPFLAGS += -I/usr/local/include
TF_CFLAGS += -g
prefix := @prefix@
exec_prefix := @exec_prefix@
-# These two use prefix and exec_prefix
bindir := @bindir@
datarootdir := @datarootdir@
+datadir := @datadir@
FLEX := @FLEX@
BISON := @BISON@
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;
}
Epigrams are expected in the "epigrams" subdirectory of the base
directory while tag expressions are expected to be stored below
"expressions".
+
+ If the option is not given, and the per-user epigram directory does
+ not exist, the system-wide default DATADIR() is tried. There is no
+ such fallback for tag expressions, though.
[/help]
[subcommand compgen]