Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sort: enforce minimum value of 1 for -F and -y #412

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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