After discussions with grog@ (mentor):
- When none of the directories in FORTUNE_PATH exist, abort instead of using the default FORTDIR. - Little stylify changes. - Add documentation about the FORTUNE_PATH variable. MFC after: 1 week
This commit is contained in:
parent
f61b0b51ed
commit
e46d677790
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=173401
@ -167,6 +167,15 @@ is equivalent to
|
||||
.Bd -literal -offset indent
|
||||
fortune 50% funny 50% not-funny
|
||||
.Ed
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width Pa -compact
|
||||
.It FORTUNE_PATH
|
||||
The search path for the data files. It is a colon-separated list
|
||||
of directories in which
|
||||
.Nm
|
||||
looks for data files. If not set it will default to /usr/games/fortune.
|
||||
If none of the directories specified exist, it will print a warning and exit.
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width Pa -compact
|
||||
.It Pa /usr/games/fortune
|
||||
|
@ -1427,13 +1427,15 @@ usage()
|
||||
void
|
||||
getpath(void)
|
||||
{
|
||||
int nstr;
|
||||
int nstr, foundenv;
|
||||
char *pch, **ppch, *str, *path;
|
||||
|
||||
foundenv = 1;
|
||||
Fortune_path = getenv("FORTUNE_PATH");
|
||||
|
||||
if (Fortune_path == NULL)
|
||||
Fortune_path = "";
|
||||
if (Fortune_path == NULL) {
|
||||
Fortune_path = FORTDIR;
|
||||
foundenv = 0;
|
||||
}
|
||||
path = strdup(Fortune_path);
|
||||
|
||||
for (nstr = 2, pch = path; *pch != '\0'; pch++) {
|
||||
@ -1452,11 +1454,15 @@ getpath(void)
|
||||
}
|
||||
str = strtok(NULL, ":");
|
||||
}
|
||||
|
||||
if (nstr == 0) {
|
||||
if (foundenv == 1) {
|
||||
fprintf(stderr,
|
||||
"fortune: FORTUNE_PATH: None of the specified "
|
||||
"directories found.\n");
|
||||
exit(1);
|
||||
}
|
||||
free(path);
|
||||
Fortune_path_arr[0] = FORTDIR;
|
||||
if (strlen(Fortune_path))
|
||||
fprintf(stderr,
|
||||
"Ignoring FORTUNE_PATH; no directories found.\n");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user