Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for finding fortune files from XDG_DATA_DIRS #77

Closed
wants to merge 2 commits into from

Conversation

ralismark
Copy link
Contributor

@ralismark ralismark commented Mar 1, 2023

Resolves #74.

This reworks support for FORTDIR/OFFDIR and LOCFORTDIR/LOCOFFDIR to support any amount of directories. I've also refactored the fortune file lookup logic to be more sensible.


My intention for the new lookup logic is as follows:

  • If the name starts with / or ./ or ../, then treat it as absolute/relative to current directory. Don't do any further processing.
  • If the name ends with -o, strip that suffix and look in offensive dirs instead of regular fortune dirs. This matches the BSD-compatibility feature.
  • For each fortune directory <fortdir> (out of paths in $XDG_DATA_DIR, FORTDIR, and LOCFORTDIR, or the corresponding offensive dirs):
    • For each language <lang>, try <fortdir>/<lang>/<name>, then try <fortdir>/<name>
    • Take the first one that's found, don't use all found paths.
  • If still no fortune is found, try using the original name as a path relative to the current directory.

Does this look ok?


Remaining work:

  • Localisation support
  • Move XDGFORTDIR and XDGOFFDIR to CMake
  • Support for probabilities for the all argument e.g. fortune 9% all

@shlomif
Copy link
Owner

shlomif commented Mar 1, 2023

Hi @ralismark !

  1. please keep debugprint().
  2. The changes are far too intrusive. please split them into several single-purpose-changes pullreqs.

@ralismark
Copy link
Contributor Author

Will do! I'll split this up into a few smaller standalone PRs.

@shlomif
Copy link
Owner

shlomif commented Mar 2, 2023 via email

@shlomif
Copy link
Owner

shlomif commented Mar 7, 2023

Per my earlier comments, I am closing this pullreq.

@shlomif shlomif closed this Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

$XDG_DATA_DIRS and $XDG_DATA_HOME support
2 participants