shlomif / fortune-mod

Implementation of the Unix fortune command for displaying a random quotation, for Linux and other systems.
http://www.shlomifish.org/open-source/projects/fortune-mod/
Other
412 stars 59 forks source link

Fix BSD-style -o suffix #78

Closed ralismark closed 1 year ago

ralismark commented 1 year ago

This fixes this feature that is documented in the manual:

A plain name (i.e., not a path to a file or directory) that ends in “-o” will be assumed to be an offensive database, and will have its suffix stripped off and be searched in the offensive directory (even if the neither of the -a or -o options were specified).

An example of this is running fortune 90% politics 10% politics-o, which produces unoffensive political fortunes 90% of the time and offensive ones 10% of the time. Also supported is the special argument all-o, which corresponds to all offensive fortunes, so you can do e.g. fortune 90% all 10% all-o.

The existing code to handle *-o was quite broken and didn't run when it should. This change removes that and reimplements it in form_file_list(), which also avoids some duplication regarding how OFFDIR/LOCOFFDIR are used.

shlomif commented 1 year ago

@ralismark : merged, thanks.