From 0a4fb31929383d7825a85f54650019a5e768478d Mon Sep 17 00:00:00 2001 From: Michael Mikonos <127171689+mknos@users.noreply.github.com> Date: Fri, 29 Dec 2023 19:00:29 +0800 Subject: [PATCH] fortune: fail for bad options * Print usage and exit if an unknown option was entered, following OpenBSD version[1] * -h is not really an option * Mention -n option in usage string as done in SYNOPSIS * Document the purpose of -d flag in usage string and pod 1. https://github.com/openbsd/src/blob/master/games/fortune/fortune/fortune.c#L304 --- bin/fortune | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/fortune b/bin/fortune index 160dcc3c..3f65272c 100755 --- a/bin/fortune +++ b/bin/fortune @@ -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}; @@ -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}) { @@ -956,11 +954,12 @@ sub print_help print <