Python version of old BSD Unix fortune program

## Project description

# Introduction

fortune is a stripped-down implementation of the classic BSD Unix fortune command. It combines the capabilities of the strfile command (which produces the fortune index file) and the fortune command (which displays a random fortune). It reads the traditional fortune program’s text file format.

# Usage

Usage:

fortune [OPTIONS] /path/to/fortunes

OPTIONS

-h, --help

Show usage and exit.

-u, --update

Update the index file.

-q, --quiet

When updating the index file, do so quietly.

-V, --version

Show version and exit.

If you omit the path, fortune looks at the FORTUNE_FILE environment variable. If that environment variable isn’t set, fortune aborts.

A fortune cookie file is a text file full of quotes. The format is simple: The file consists of paragraphs separated by lines containing a single ‘%’ character. For example:

A little caution outflanks a large cavalry.
-- Bismarck
%
A little retrospection shows that although many fine, useful software
systems have been designed by committees and built as part of multipart
projects, those software systems that have excited passionate fans are
those that are the products of one or a few designing minds, great
designers. Consider Unix, APL, Pascal, Modula, the Smalltalk interface,
even Fortran; and contrast them with Cobol, PL/I, Algol, MVS/370, and
MS-DOS.
-- Fred Brooks, Jr.
%
A man is not old until regrets take the place of dreams.
-- John Barrymore

# Generating a Random Fortune

Just run:

fortune /path/to/fortunes

If your FORTUNE_FILE environment variable is set, you can run it as

fortune

# Differences

This version of fortune does not provide some of the more advanced capabilities of the original BSD program. For instance, it lacks:

• the ability to mark offensive and inoffensive fortunes

• the ability to separate long and short quotes

• the ability to print all fortunes matching a regular expression

It does, however, provide the most important function: The ability to display a random quote from a set of quotes.

## Project details

Uploaded source
Uploaded py2 py3