Page MenuHomeFreeBSD

fortune: fall back to all databases if fortunes is missing
ClosedPublic

Authored by dteske on Thu, Aug 20, 8:09 PM.
Tags
None
Referenced Files
F168713120: D59057.id185295.diff
Sat, Aug 29, 6:48 PM
Unknown Object (File)
Wed, Aug 26, 3:31 AM
Unknown Object (File)
Wed, Aug 26, 3:24 AM
Unknown Object (File)
Wed, Aug 26, 3:22 AM
Unknown Object (File)
Tue, Aug 25, 7:53 PM
Unknown Object (File)
Tue, Aug 25, 6:19 PM
Unknown Object (File)
Fri, Aug 21, 9:31 PM
Unknown Object (File)
Fri, Aug 21, 11:46 AM
Subscribers

Details

Summary

With no file argument, fortune looks for a database named fortunes
in FORTDIR. The base system has not shipped that file since
0538d7bbe620 (FreeBSD 12), only freebsd-tips, so the default
invocation failed even though a valid database remained. Callers
such as xlockmore's marquee and nose modes (fortune -s) then
displayed the error as the epigram.

If the named fortunes file is absent, scan every database in the
existing search path. /usr/local/share/games/fortune stays on that
path so fortune-mod-* packages keep working; when
fortune-mod-freebsd-classic restores the fortunes file, it is still
preferred. fortune -f with no arguments lists the same files that
would be searched.

MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Add missing preposition (ending -> ending in)

As an alternative, could we just symlink freebsd-tips to fortunes?

In D59057#1354640, @fuz wrote:

As an alternative, could we just symlink freebsd-tips to fortunes?

A symlink would make the same database show up twice, affecting both fortune all and fortune -f. Default fortune also loads every file named fortunes in the search path, so you would get epigrams from both the base symlink (to freebsd-tips) and /usr/local/share/games/fortune/fortunes (if/when fortune-mod-freebsd-classic is installed). Unlike fortune all, a plain fortune is supposed to use the file named fortunes, not a mix of epigrams from more than one database.

This patch: first search for fortunes. If fortune-mod-freebsd-classic is not installed, no such file is found (stock base), then use freebsd-tips, so fortune works with what we ship. Port installed then that file is the default again (fortune or fortune fortunes). fortune freebsd-tips is unchanged. xlock from xlockmore port/pkg works without requiring fortune-mod-freebsd-classic.

As a maintainer of some fortune databases, I say: thank you madam. I was always too lazy to look into this / not a good programmer.

This revision is now accepted and ready to land.Sat, Aug 22, 11:41 PM
usr.bin/fortune/fortune/fortune.6
181

Macros in list widths is an undefined behavior which even can render as -1 character in some implementations.

I guess you could do it that way.

dteske added inline comments.
usr.bin/fortune/fortune/fortune.6
181

Noted. It was already there before me, so I will raise a different review to get rid of it

This revision was automatically updated to reflect the committed changes.
dteske marked an inline comment as done.