Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fortune: fail for bad options #392

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions bin/fortune
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ my $STR_ROTATED = 0x4;
# Globals
my (%opts);

getopts('adefhilosvwm:n:', \%opts);
getopts('adefilosvwm:n:', \%opts) or print_help();

my $debug = $opts{d};

Expand Down Expand Up @@ -75,8 +75,6 @@ my %Top_item = ( name => 'Top level file/directory list',

# this is the main routine of the program

if ($opts{h}) { print_help(); }

build_file_list( list_files( \%Top_item ) );

if ($opts{m}) {
Expand Down Expand Up @@ -956,11 +954,12 @@ sub print_help

print <<EOF;

Usage: $0 [-adefhilosw] [-m pattern] [[N%] file/dir/all]
Usage: $0 [-adefilosw] [-n length] [-m pattern] [[N%] file/dir/all]

See the POD for more information.

-a Choose from all lists of maxims, both offensive and not.
-d Enable debug messages
-e Consider all fortune files to be of equal size.
-f Print out the list of files which would be searched.
-l Long dictums only.
Expand All @@ -983,8 +982,6 @@ EOF
exit 1;
}

1;

__END__

=pod
Expand All @@ -1007,6 +1004,8 @@ not. The options are as follows:
-a Choose from all lists of maxims, both offensive and not. (See the
-o option for more information on offensive fortunes.)

-d Enable debug messages.

-e Consider all fortune files to be of equal size (see discussion be-
low on multiple files).

Expand Down