Skip to content

Commit 1e85ad5

Browse files
authored
fortune: file extension blacklist correction
* The "ins" suffixes are ins.c, ins.ftn and ins.pas---one of these was written with a comma [1] * Allow --version to work the same as -v, instead of printing an ugly getopt message 1. https://bitsavers.trailing-edge.com/pdf/apollo/000792-A01_Domain_Pascal_Language_Reference_Dec90.pdf (page 189)
1 parent f2d8543 commit 1e85ad5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

bin/fortune

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,12 @@ my $STR_ROTATED = 0x4;
4444
my (%opts);
4545

4646
getopts('adefilosvwm:n:', \%opts) or print_help();
47+
VERSION_MESSAGE() if $opts{'v'};
4748

4849
my $debug = $opts{d};
4950

5051
my $SHORT_LENGTH = $opts{n} || 160;
5152

52-
if ($opts{v}) {
53-
print "\n\n$0 $VERSION\n\n";
54-
exit 1;
55-
}
56-
5753
if ($debug) {
5854
warn "opts are:\n";
5955
foreach (keys %opts) {
@@ -106,6 +102,11 @@ if ($opts{m}) {
106102
# Sub Routines
107103
#
108104

105+
sub VERSION_MESSAGE {
106+
print "$0 version $VERSION\n";
107+
exit 0;
108+
}
109+
109110
# build_file_list
110111
#
111112
# build list of the available files
@@ -279,7 +280,7 @@ sub is_fortune_file
279280
warn "$msg FALSE (can't read file)\n" if $debug;
280281
return 0;
281282
}
282-
my @illegal_suffixes = qw(dat pos c h p i f pas ftn ins.c ins,pas
283+
my @illegal_suffixes = qw(dat pos c h p i f pas ftn ins.c ins.pas
283284
ins.ftn sml);
284285
foreach (@illegal_suffixes) {
285286
if ( $path =~ /\.$_$/ ) {

0 commit comments

Comments
 (0)