Skip to content

Commit

Permalink
Merge pull request #193 from mknos/split-badarg
Browse files Browse the repository at this point in the history
split: improve argument handling
  • Loading branch information
briandfoy committed Jul 7, 2023
2 parents b137ede + 829a3bc commit 3e20e1e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions bin/split
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,19 @@ exit 1;

#### Main program starts here. ####

## Grab options
getopts ('b:l:p:?', \my %opt);
getopts('b:l:p:', \my %opt) or clue;

clue if $opt{"?"}; # heeeeeeeeeeelp!

## Open whatever needs opening
my $infile = (defined $ARGV[0] ? $ARGV[0] : "-");
my $prefix = ($ARGV[1] ? "$ARGV[1]" : "x");
my $infile = shift;
my $prefix = shift;
die("$me: extra operand: $ARGV[0]\n") if @ARGV;
unless (defined $infile) {
$infile = '-';
}
unless (defined $prefix && length $prefix) {
$prefix = 'x';
}

die("$me: $infile: is a directory\n") if (-d $infile);
open (INFILE, '<', $infile) || die "$me: Can't open $infile: $!\n";
binmode(INFILE);
## Byte operations.
Expand Down Expand Up @@ -240,4 +244,3 @@ way you wish, provided you do not restrict others to do the same.
=cut


0 comments on commit 3e20e1e

Please sign in to comment.