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.\"	@(#)fortune.6	8.3 (Berkeley) 4/19/94
32.\"
33.Dd July 1, 2021
34.Dt FORTUNE 6
35.Os
36.Sh NAME
37.Nm fortune
38.Nd "print a random, hopefully interesting, adage"
39.Sh SYNOPSIS
40.Nm
41.Op Fl aDefilosw
42.Op Fl m Ar pattern
43.Oo
44.Op Ar \&N%
45.Ar file Ns / Ns Ar directory Ns / Ns Cm all
46.Oc
47.Sh DESCRIPTION
48When
49.Nm
50is run with no arguments it prints out a random epigram.
51Epigrams are divided into several categories, where each category
52is subdivided into those which are potentially offensive and those
53which are not.
54The options are as follows:
55.Bl -tag -width indent
56.It Fl a
57Choose from all lists of maxims, both offensive and not.
58(See the
59.Fl o
60option for more information on offensive fortunes.)
61.It Fl D
62Enable additional debugging output.
63Specify this option multiple times for more verbose output.
64Only available if compiled with
65.Li -DDEBUG .
66.It Fl e
67Consider all fortune files to be of equal size (see discussion below
68on multiple files).
69.It Fl f
70Print out the list of files which would be searched, but do not
71print a fortune.
72.It Fl l
73Long dictums only.
74.It Fl m Ar pattern
75Print out all fortunes which match the regular expression
76.Ar pattern .
77See
78.Xr regex 3
79for a description of patterns.
80.It Fl o
81Choose only from potentially offensive aphorisms.
82.Bf -symbolic
83Please, please, please request a potentially offensive fortune if and
84only if you believe, deep down in your heart, that you are willing
85to be offended.
86(And that if you are not willing, you will just quit using
87.Fl o
88rather than give us
89grief about it, okay?)
90.Ef
91.Bd -unfilled -offset indent
92\&... let us keep in mind the basic governing philosophy
93of The Brotherhood, as handsomely summarized in these words:
94we believe in healthy, hearty laughter -- at the expense of
95the whole human race, if needs be.
96Needs be.
97                           --H. Allen Smith, "Rude Jokes"
98.Ed
99.It Fl s
100Short apothegms only.
101.It Fl i
102Ignore case for
103.Fl m
104patterns.
105.It Fl w
106Wait before termination for an amount of time calculated from the
107number of characters in the message.
108This is useful if it is executed as part of the logout procedure
109to guarantee that the message can be read before the screen is cleared.
110.El
111.Pp
112The user may specify alternate sayings.
113You can specify a specific file, a directory which contains one or
114more files, or the special word
115.Cm all
116which says to use all the standard databases.
117Any of these may be preceded by a percentage, which is a number
118.Ar N
119between 0 and 100 inclusive, followed by a
120.Ql % .
121If it is, there will be an
122.Ar N
123percent probability that an adage will be picked from that file
124or directory.
125If the percentages do not sum to 100, and there are specifications
126without percentages, the remaining percent will apply to those files
127and/or directories, in which case the probability of selecting from
128one of them will be based on their relative sizes.
129.Pp
130As an example, given two databases
131.Pa funny
132and
133.Pa not-funny ,
134with
135.Pa funny
136twice as big, saying
137.Pp
138.Dl "fortune funny not-funny"
139.Pp
140will get you fortunes out of
141.Pa funny
142two-thirds of the time.
143The command
144.Pp
145.Dl "fortune 90% funny 10% not-funny"
146.Pp
147will pick out 90% of its fortunes from
148.Pa funny
149(the
150.Dq Li "10% not-funny"
151is unnecessary, since 10% is all that is left).
152The
153.Fl e
154option says to consider all files equal;
155thus
156.Pp
157.Dl "fortune -e funny not-funny"
158.Pp
159is equivalent to
160.Pp
161.Dl "fortune 50% funny 50% not-funny"
162.Sh ENVIRONMENT
163.Bl -tag -width ".Ev FORTUNE_PATH"
164.It Ev FORTUNE_PATH
165The search path for the data files.
166It is a colon-separated list of directories in which
167.Nm
168looks for data files.
169If not set it will default to
170.Pa /usr/share/games/fortune:/usr/local/share/games/fortune .
171If none of the directories specified exist, it will print a warning and exit.
172.It Ev FORTUNE_SAVESTATE
173If set, fortune will save some state about what fortune
174it was up to on disk.
175.El
176.Sh FILES
177.Bl -tag -width ".Pa /usr/share/games/fortune/*"
178.It Pa /usr/share/games/fortune/*
179the fortunes databases (those files ending
180.Dq Pa -o
181contain the
182.Sy offensive
183fortunes)
184.El
185.Sh EXIT STATUS
186.Ex -std
187In particular, if
188.Fl l ,
189.Fl m ,
190or
191.Fl s
192is specified, failure to find a matching citation in the selected
193files counts as an error.
194.Sh SEE ALSO
195.Xr arc4random_uniform 3 ,
196.Xr regcomp 3 ,
197.Xr regex 3 ,
198.Xr strfile 8
199.Sh HISTORY
200The
201.Nm
202utility first appeared
203.At v7 .
204