From 04ca5a54fed1f02a9089a6c1b5364cdf9ef190eb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 4 Jan 2010 19:09:14 -0500 Subject: [PATCH] don't call getopt recursively That messes with the return value of the outer call. --- Debian/Debhelper/Dh_Getopt.pm | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Debian/Debhelper/Dh_Getopt.pm b/Debian/Debhelper/Dh_Getopt.pm index 4df3eed..f27775b 100644 --- a/Debian/Debhelper/Dh_Getopt.pm +++ b/Debian/Debhelper/Dh_Getopt.pm @@ -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; } -- 2.39.2