Skip to content

Commit

Permalink
Merge pull request #352 from mknos/pr-checknum
Browse files Browse the repository at this point in the history
pr: validate -o COUNT
  • Loading branch information
briandfoy authored Nov 30, 2023
2 parents 353a290 + d912c08 commit 9dc8209
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions bin/pr
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ while (@ARGV && $ARGV[0] =~ /^-(.+)/ && (shift, ($_ = $1), 1)) {

if (s/^o//) {
warn "-o option already used" if $offsetspaces;
$offsetspaces=shift;
$offsetspaces = checknum(shift);
redo OPTION;
}

Expand Down Expand Up @@ -232,9 +232,15 @@ USAGE
exit EX_FAILURE;
}

#
# FUNCTIONS
#
sub checknum {
my $n = shift;
if (length($n) == 0 || $n !~ m/\A[0-9]+\Z/) {
warn "$Program: invalid number: '$n'\n";
exit EX_FAILURE;
}
return int($n);
}

sub create_col {
my($col)=@_;

Expand Down

0 comments on commit 9dc8209

Please sign in to comment.