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

par: reject bad options #752

Merged
merged 1 commit into from
Oct 3, 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
19 changes: 6 additions & 13 deletions bin/par
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ my $VERSION = '0.08';

use File::Find;
use File::Basename;
use Getopt::Std qw(getopts);
use Cwd;

eval 'use Stat::lsMode';
Expand All @@ -35,21 +36,13 @@ binmode STDOUT;
# Are we 'par' or 'shar'?
($0) = $0 =~ /(\w+)$/;

# Check for arguments.
@ARGV or die "usage: $0 [-s submitter] [-STBqvz] file [files...]\n";
sub usage {
die "usage: $0 [-s submitter] [-STBqvz] file...\n";
}

# Get options.
my %opts;
while (@ARGV && $ARGV[0] =~ s/^-//) {
local $_ = shift;
while (/([sSTBVqvz])/g) {
if ($1 eq 's') {
$opts{'s'} = /\G(.*)/g && $1 ? $1 : shift;
} else {
$opts{$1}++;
}
}
}
getopts('s:STBqvz', \%opts) or usage();
@ARGV or usage();

# Print version.
if ($opts{'v'}) {
Expand Down
Loading