Skip to content

Commit

Permalink
Merge pull request #412 from mknos/sort-yvalid
Browse files Browse the repository at this point in the history
sort: enforce minimum value of 1 for -F and -y
  • Loading branch information
briandfoy authored Jan 23, 2024
2 parents e27836a + 53737f3 commit 7cd51a3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bin/sort
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,15 @@ sub _sort_file {

# set output and other defaults
$opts->{o} = !$opts->{o} ? '' : $opts->{o};
$opts->{'y'} ||= $ENV{MAX_SORT_RECORDS} || 200000; # default max records
$opts->{F} ||= $ENV{MAX_SORT_FILES} || 40; # default max files

$opts->{'y'} ||= $ENV{'MAX_SORT_RECORDS'} || 200000; # default max records
$opts->{'F'} ||= $ENV{'MAX_SORT_FILES'} || 40; # default max files
if (defined $opts->{'F'}) {
die "option -F expects a positive number\n" if (int($opts->{'F'}) < 1);
}
if (defined $opts->{'y'}) {
die "option -y expects a positive number\n" if (int($opts->{'y'}) < 1);
}

# see big ol' mess below
_make_sort_sub($opts);
Expand Down

0 comments on commit 7cd51a3

Please sign in to comment.