Page MenuHomeFreeBSD

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

Authored by dteske on Aug 20 2026, 8:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Sep 20, 3:44 AM
Unknown Object (File)
Sat, Sep 19, 6:07 AM
Unknown Object (File)
Sat, Sep 19, 2:56 AM
Unknown Object (File)
Fri, Sep 18, 10:19 PM
Unknown Object (File)
Fri, Sep 18, 2:02 AM
Unknown Object (File)
Fri, Sep 18, 1:51 AM
Unknown Object (File)
Thu, Sep 17, 1:27 PM
Unknown Object (File)
Thu, Sep 17, 7:15 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.