GFORTUNE(6)

NAME
gfortune - print a random, possibly interesting, adage

SYNOPSIS
gfortune [-aeEfhilosrw] [-m pattern] [-L num] [-N num] [-S num] [[N%] file/dir/all]

DESCRIPTION
When gfortune is run with no arguments it prints out a random epigram. Epigrams are divided into categories, and each category may be subdivided into those which are potentially offensive and those which are not. The options are as follows:

-a  Choose from all lists of maxims, both offensive and not.

-e  Consider all fortune files to be of equal size (see discussion below on selection modes).

-E  Consider all fortune files in each directory to be of equal size see discussion below on selection modes).

-f  Print out the list of files which would be searched, but don't print a fortune.

-h  Print a short help screen.

-i  Ignore case when matching regular expressions.

-l  Long dictums only.

-m  Print out all fortunes which match the regular expression pattern. See grep(1) for a description of patterns.

-o  Choose only from potentially offensive aphorisms. If you get offended, don't tell me. Quit using -o.

-r  Prevents recursion beyond the directories given on the command line (or the base default directory if none given).

-s  Short fortunes only.

-w  Wait before termination for an amount of time calculated from the number of characters in the message. This is useful if it is executed as part of the logout procedure to guarantee that the message can be read before the screen is cleared.

-L  Set the minimum length (in characters) to num for a 'long' fortune. (Assumes -l).

-N  Set the maximum length (in lines) to num for a fortune (normally 999).

-S  Set the maximum length (in characters) to num for a 'short' fortune. (Assumes -s).

SELECTION MODES
gfortune has three built in probability modes for selecting files. Probabilities may also be specified by the user.

All fortunes equal (default) is the default mode. This gives each fortune in all files specified the same probability of being displayed.

All files equal (-e) will give all files in all nested directories under the base fortune directory specified equal probability. Hence subdirectories with more files in them have more chance of being chosen than relatively empty directories.

All files in directory equal (-E) will give all files in each directory the same probability of being chosen. A file is independently selected from each directory being processed, each file in the directory having an equal probabiltiy of being chosen from it.

FORTUNE FILES
The user may specify alternate sayings. You can specify a specific file, a directory which contains one or more files and nested directories, or the special word all which says to use all the standard databases. Any of these may be preceded by a percentage, which is a number N between 0 and 100 inclusive, followed by a %. If it is, there will be a N percent probability that an adage will be picked from that file or directory. If the percentages do not sum to 100, and there are specifications without percentages, the remaining percent will apply to those files and/or directories.

As an example, given two databases funny and not-funny, with funny twice as big, saying
    fortune funny not-funny
will get you fortunes out of funny two-thirds of the time. The command
    fortune 90% funny 10% not-funny
will pick out 90% of its fortunes from funny (the ``10% not-funny'' is unnecessary, since 10% is all that's left). The -e option says to consider all files equal; thus
    fortune -e
is equivalent to
    fortune 50% funny 50% not-funny
Dot files may not be added.

The selection modes apply to files specified on the command line as well as files found in subdirectories, so
    fortune -E work people
will give the files 'work' and 'people' equal probability reguardless of their size and contents, whereas
    gfortune work people
would base probability on the sizes of the files.

OFFENSIVENESS
Offensive fortune files are any fortune files starting with the 9 letters offensive, for example offensive-work or offensive-people. Any file in a subdirectory starting with offensive is also classified as offensive, as is any file in a directory of any name nested below that. So the file
    /var/lib/games/fortunes/bierce/bierce-a.txt
is not offensive, but the files
    /var/lib/games/fortunes/offensive-work
    /var/lib/games/fortunes/work/offensive/others
    /var/lib/games/fortunes/work/offensive/bosses/mine
are classified as offensive.

RECURSION
gfortune will normally recurse from any starting directory it is given. An alternate directory may be provided on the command line, and the recursion may be inhibited using the -r flag.

ERROR MESSAGES

No fortunes found
    The program could not find any fortunes in the specified category, offensiveness or given directories. (empty files?)

Percentages must be integers
    Self explanatory, command line syntax.

Percentages must precede filenames
    Self explanatory, command line syntax.

Percentages must be <= 100%
    Self explanatory, command line syntax.

No files found
    The program could not find any fortunes in the specified category, offensiveness or given directories. (no files?)

Failed to add file
    The filename given on the command line is empty, not a valid fortune file, or is a directory with no fortune files in it.

Too many tries
    The options given fortune via -S, -L and -N options were too restrictive for gfortune to find a matching epigram within reasonable time.

BUGS
Bloatware. Also, I can't write man pages so I'm guessing.

WISH LIST
Might not compile elsewhere. I would like BSD, Solaris, SysV. However, the source uses regcomp(3) and rexeec(3). Still uses time(2). I am too lazy to do a full and consistent implementation of wait time to include min wait, wait per character, max wait, etc.

FILES
/var/lib/games/fortunes/
/usr/games/gfortune

AUTHOR
Shevek <shevek@white-star.com>

Parts of this code were based on the Berkeley fortune program released by Ken Arnold.

SEE ALSO
regex(7) grep(1) regexec(3) strfile(8)