mirror of https://github.com/ipxe/ipxe.git
[build] Simplify use of Getopt::Long in padimg.pl
Sometimes it's just so much fun doing things the complicated way that you forget to check the man page for the existence of a simpler syntax.pull/1/head
parent
7aee624881
commit
b4a87daeb9
|
@ -9,16 +9,15 @@ my $verbosity = 0;
|
||||||
my $blksize = 512;
|
my $blksize = 512;
|
||||||
my $byte = 0;
|
my $byte = 0;
|
||||||
|
|
||||||
my $opts = {
|
my %opts = (
|
||||||
'verbose|v+' => sub { $verbosity++; },
|
'verbose|v+' => sub { $verbosity++; },
|
||||||
'quiet|q+' => sub { $verbosity--; },
|
'quiet|q+' => sub { $verbosity--; },
|
||||||
'blksize|s=o' => sub { $blksize = $_[1]; },
|
'blksize|s=o' => sub { $blksize = $_[1]; },
|
||||||
'byte|b=o' => sub { $byte = $_[1]; },
|
'byte|b=o' => sub { $byte = $_[1]; },
|
||||||
};
|
);
|
||||||
|
|
||||||
Getopt::Long::Configure ( 'bundling', 'auto_abbrev' );
|
Getopt::Long::Configure ( 'bundling', 'auto_abbrev' );
|
||||||
GetOptions ( { map { /^(\w+)/; $1 => $opts->{$_} } keys %$opts }, keys %$opts )
|
GetOptions ( %opts ) or die "Could not parse command-line options\n";
|
||||||
or die "Could not parse command-line options\n";
|
|
||||||
|
|
||||||
while ( my $filename = shift ) {
|
while ( my $filename = shift ) {
|
||||||
die "$filename is not a file\n" unless -f $filename;
|
die "$filename is not a file\n" unless -f $filename;
|
||||||
|
|
Loading…
Reference in New Issue