1
0
mirror of https://github.com/Yubico/yubikey-ksm.git synced 2025-01-19 16:52:16 +01:00

Fix command line handling.

This commit is contained in:
Simon Josefsson 2010-11-11 17:15:23 +00:00
parent 19e207c5f5
commit e128f2b782

View File

@ -36,7 +36,10 @@ my $device = "/dev/random";
sub usage { sub usage {
print "Usage: ykksm-gen-keys.pl [--verbose] [--help]\n"; print "Usage: ykksm-gen-keys.pl [--verbose] [--help]\n";
print " [--urandom] [--progflags PROGFLAGS] START [END]\n"; print " [--urandom]\n";
print " [--progflags PROGFLAGS]\n";
print " [--pskc]\n";
print " START [END]\n";
print "\n"; print "\n";
print " Tool to generate keys on the YKKSM-KEYPROV format.\n"; print " Tool to generate keys on the YKKSM-KEYPROV format.\n";
print "\n"; print "\n";
@ -96,9 +99,9 @@ if ($#ARGV==-1) {
my $verbose = 0; my $verbose = 0;
my $pskc = 0; my $pskc = 0;
my $progflags; my $progflags;
my $start; my $start = "";
my $end; my $end = "";
while ($ARGV[0]) { while (defined($ARGV[0])) {
my $cmd = shift @ARGV; my $cmd = shift @ARGV;
if (($cmd eq "-v") || ($cmd eq "--verbose")) { if (($cmd eq "-v") || ($cmd eq "--verbose")) {
$verbose = 1; $verbose = 1;
@ -111,16 +114,16 @@ while ($ARGV[0]) {
} elsif ($cmd eq "--pskc") { } elsif ($cmd eq "--pskc") {
$pskc = 1; $pskc = 1;
} elsif ($cmd =~ m/^[0-9]+/) { } elsif ($cmd =~ m/^[0-9]+/) {
if (!$start) { if ($start eq "") {
$start = $cmd; $start = $cmd;
} elsif (!$end) { } elsif ($end eq "") {
$end = $cmd; $end = $cmd;
} else { } else {
die "Invalid extra argument: $cmd"; die "Invalid extra argument: $cmd";
} }
} }
} }
die "Missing START parameter, try --help" if ($start eq "");
$end = $start if (!$end); $end = $start if (!$end);
my $now = strftime "%Y-%m-%dT%H:%M:%S", localtime; my $now = strftime "%Y-%m-%dT%H:%M:%S", localtime;