xref: /freebsd/usr.bin/fortune/fortune/fortune.6 (revision 3494f7c0)
1.\" Copyright (c) 1985, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Ken Arnold.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.Dd July 1, 2021
32.Dt FORTUNE 6
33.Os
34.Sh NAME
35.Nm fortune
36.Nd "print a random, hopefully interesting, adage"
37.Sh SYNOPSIS
38.Nm
39.Op Fl aDefilosw
40.Op Fl m Ar pattern
41.Oo
42.Op Ar \&N%
43.Ar file Ns / Ns Ar directory Ns / Ns Cm all
44.Oc
45.Sh DESCRIPTION
46When
47.Nm
48is run with no arguments it prints out a random epigram.
49Epigrams are divided into several categories, where each category
50is subdivided into those which are potentially offensive and those
51which are not.
52The options are as follows:
53.Bl -tag -width indent
54.It Fl a
55Choose from all lists of maxims, both offensive and not.
56(See the
57.Fl o
58option for more information on offensive fortunes.)
59.It Fl D
60Enable additional debugging output.
61Specify this option multiple times for more verbose output.
62Only available if compiled with
63.Li -DDEBUG .
64.It Fl e
65Consider all fortune files to be of equal size (see discussion below
66on multiple files).
67.It Fl f
68Print out the list of files which would be searched, but do not
69print a fortune.
70.It Fl l
71Long dictums only.
72.It Fl m Ar pattern
73Print out all fortunes which match the regular expression
74.Ar pattern .
75See
76.Xr regex 3
77for a description of patterns.
78.It Fl o
79Choose only from potentially offensive aphorisms.
80.Bf -symbolic
81Please, please, please request a potentially offensive fortune if and
82only if you believe, deep down in your heart, that you are willing
83to be offended.
84(And that if you are not willing, you will just quit using
85.Fl o
86rather than give us
87grief about it, okay?)
88.Ef
89.Bd -unfilled -offset indent
90\&... let us keep in mind the basic governing philosophy
91of The Brotherhood, as handsomely summarized in these words:
92we believe in healthy, hearty laughter -- at the expense of
93the whole human race, if needs be.
94Needs be.
95                           --H. Allen Smith, "Rude Jokes"
96.Ed
97.It Fl s
98Short apothegms only.
99.It Fl i
100Ignore case for
101.Fl m
102patterns.
103.It Fl w
104Wait before termination for an amount of time calculated from the
105number of characters in the message.
106This is useful if it is executed as part of the logout procedure
107to guarantee that the message can be read before the screen is cleared.
108.El
109.Pp
110The user may specify alternate sayings.
111You can specify a specific file, a directory which contains one or
112more files, or the special word
113.Cm all
114which says to use all the standard databases.
115Any of these may be preceded by a percentage, which is a number
116.Ar N
117between 0 and 100 inclusive, followed by a
118.Ql % .
119If it is, there will be an
120.Ar N
121percent probability that an adage will be picked from that file
122or directory.
123If the percentages do not sum to 100, and there are specifications
124without percentages, the remaining percent will apply to those files
125and/or directories, in which case the probability of selecting from
126one of them will be based on their relative sizes.
127.Pp
128As an example, given two databases
129.Pa funny
130and
131.Pa not-funny ,
132with
133.Pa funny
134twice as big, saying
135.Pp
136.Dl "fortune funny not-funny"
137.Pp
138will get you fortunes out of
139.Pa funny
140two-thirds of the time.
141The command
142.Pp
143.Dl "fortune 90% funny 10% not-funny"
144.Pp
145will pick out 90% of its fortunes from
146.Pa funny
147(the
148.Dq Li "10% not-funny"
149is unnecessary, since 10% is all that is left).
150The
151.Fl e
152option says to consider all files equal;
153thus
154.Pp
155.Dl "fortune -e funny not-funny"
156.Pp
157is equivalent to
158.Pp
159.Dl "fortune 50% funny 50% not-funny"
160.Sh ENVIRONMENT
161.Bl -tag -width ".Ev FORTUNE_PATH"
162.It Ev FORTUNE_PATH
163The search path for the data files.
164It is a colon-separated list of directories in which
165.Nm
166looks for data files.
167If not set it will default to
168.Pa /usr/share/games/fortune:/usr/local/share/games/fortune .
169If none of the directories specified exist, it will print a warning and exit.
170.It Ev FORTUNE_SAVESTATE
171If set, fortune will save some state about what fortune
172it was up to on disk.
173.El
174.Sh FILES
175.Bl -tag -width ".Pa /usr/share/games/fortune/*"
176.It Pa /usr/share/games/fortune/*
177the fortunes databases (those files ending
178.Dq Pa -o
179contain the
180.Sy offensive
181fortunes)
182.El
183.Sh EXIT STATUS
184.Ex -std
185In particular, if
186.Fl l ,
187.Fl m ,
188or
189.Fl s
190is specified, failure to find a matching citation in the selected
191files counts as an error.
192.Sh SEE ALSO
193.Xr arc4random_uniform 3 ,
194.Xr regcomp 3 ,
195.Xr regex 3 ,
196.Xr strfile 8
197.Sh HISTORY
198The
199.Nm
200utility first appeared
201.At v7 .
202