chiark / gitweb /
xlog: Proper argument parser in record (no functional change)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 17 Dec 2014 16:31:37 +0000 (16:31 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 17 Dec 2014 16:39:06 +0000 (16:39 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
xlog/bin/record

index 2e9bc70..2408833 100755 (executable)
@@ -8,12 +8,20 @@ our %f;
 
 my $publish_rejections_patfile= '/dev/null';
 my $publish_rejections= 0;
-if ($ARGV[0] eq '-P') {
-    $publish_rejections= 1;
-    shift @ARGV;
-} elsif ($ARGV[0] =~ s/^\-P//) {
-    $publish_rejections= 1;
-    $publish_rejections_patfile= shift @ARGV;
+
+for (;;) {
+    last unless @ARGV;
+    last unless $ARGV[0] =~ m/^-/;
+    $_ = shift @ARGV;
+    last if m/^--?$/;
+    while (m/^-./) {
+       if (s/^-P(.*)$//) {
+           $publish_rejections= 1;
+           $publish_rejections_patfile= $1 if length $1;
+       } else {
+           die "bad option $_ ?";
+       }
+    }
 }
 
 our ($how) = @_;