]> git.donarmstrong.com Git - debhelper.git/commitdiff
don't call getopt recursively
authorJoey Hess <joey@gnu.kitenet.net>
Tue, 5 Jan 2010 00:09:14 +0000 (19:09 -0500)
committerJoey Hess <joey@gnu.kitenet.net>
Tue, 5 Jan 2010 00:09:14 +0000 (19:09 -0500)
That messes with the return value of the outer call.

Debian/Debhelper/Dh_Getopt.pm

index 4df3eed27ae26944d40afe27820e86c516ab36ca..f27775b47823833e47ae3c3f65e76db1798e33fd 100644 (file)
@@ -70,6 +70,7 @@ sub getoptions {
        my $array=shift;
        my %params=@_;
 
+       my @test;
        my %options=(   
                "v" => \$dh{VERBOSE},
                "verbose" => \$dh{VERBOSE},
@@ -130,14 +131,8 @@ sub getoptions {
                
                "ignore=s" => \&AddIgnore,
 
-               "O=s" => sub { my($option,$value)=@_;
-                       # Try to parse an option, but ignore it
-                       # if it is not known.
-                       if (getoptions([$value], %params, test => 1)) {
-                               getoptions([$value], %params);
-                       }
-               },
-
+               "O=s" => sub { push @test, $_[1] },
+             
                (ref $params{options} ? %{$params{options}} : ()) ,
 
                "<>" => \&NonOption,
@@ -159,6 +154,14 @@ sub getoptions {
                $SIG{__WARN__}=$oldwarn;
        }
 
+       foreach my $opt (@test) {
+               # Try to parse an option, but ignore it
+               # if it is not known.
+               if (getoptions([$opt], %params, test => 1)) {
+                       getoptions([$opt], %params);
+               }
+       }
+
        return 1 if $params{ignore_unknown_options};
        return $ret;
 }