Skip to content

Commit

Permalink
words: throw error for too many args (#650)
Browse files Browse the repository at this point in the history
* words command takes only one argument; show an error if user accidentally provides 2 arguments instead of ignoring the second
* Zero-args case was already handled
  • Loading branch information
mknos authored Jun 11, 2024
1 parent 2874d3c commit de844ae
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bin/words
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ my $Program = basename($0);

getopts('m:w:') or usage();
usage() unless @ARGV;
my $letters = shift;
if (@ARGV) {
warn "$Program: extra argument: '$ARGV[0]'\n";
usage();
}

my $wordlist;
if (defined $opt_w) {
Expand Down Expand Up @@ -58,7 +63,6 @@ unless (open $dict, '<', $wordlist) {

$| = 1;

my $letters = shift;
$letters = lc $letters; # convert to lowercase
$letters =~ tr/a-z//cd; # strip non-letter characters

Expand Down

0 comments on commit de844ae

Please sign in to comment.