diff options
author | Joey Hess <joey@gnu.kitenet.net> | 2009-06-29 16:10:48 -0400 |
---|---|---|
committer | Joey Hess <joey@gnu.kitenet.net> | 2009-06-29 16:10:48 -0400 |
commit | afabee81e04c52cae5cbf55b8ba4566659505e9b (patch) | |
tree | a79d87c2bf3c9417206a99ef299da3cf5ebf6ebe /Debian/Debhelper/Dh_Getopt.pm | |
parent | 86e65737a05bc7dc5e911577bf96e9539ab759c2 (diff) |
Make dh not complain about unknown, command-specific options passed to it
and further suppress warnings about such options it passes on to debhelper
commands. This was attempted incompletely before in version 7.2.17.
Diffstat (limited to 'Debian/Debhelper/Dh_Getopt.pm')
-rw-r--r-- | Debian/Debhelper/Dh_Getopt.pm | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/Debian/Debhelper/Dh_Getopt.pm b/Debian/Debhelper/Dh_Getopt.pm index 9868124c..86f3cdba 100644 --- a/Debian/Debhelper/Dh_Getopt.pm +++ b/Debian/Debhelper/Dh_Getopt.pm @@ -72,8 +72,14 @@ sub NonOption { sub getoptions { my $array=shift; my %options=%{shift()} if ref $_[0]; + + my $oldwarn; + if ($ENV{DH_IGNORE_UNKNOWN_OPTIONS}) { + $oldwarn=$SIG{__WARN__}; + $SIG{__WARN__}=sub {}; + } - Getopt::Long::GetOptionsFromArray($array, + my $ret=Getopt::Long::GetOptionsFromArray($array, "v" => \$dh{VERBOSE}, "verbose" => \$dh{VERBOSE}, @@ -136,7 +142,15 @@ sub getoptions { %options, "<>" => \&NonOption, - ) + ); + + if ($ENV{DH_IGNORE_UNKNOWN_OPTIONS}) { + $SIG{__WARN__}=$oldwarn; + return 1; + } + else { + return $ret; + } } sub split_options_string { @@ -155,11 +169,7 @@ sub parseopts { # dh through an override target to a command. if (defined $ENV{DH_INTERNAL_OPTIONS}) { @ARGV_extra=split_options_string($ENV{DH_INTERNAL_OPTIONS}); - # Unknown options will be silently ignored. - my $oldwarn=$SIG{__WARN__}; - $SIG{__WARN__}=sub {}; getoptions(\@ARGV_extra, $options); - $SIG{__WARN__}=$oldwarn; # Avoid forcing acting on packages specified in # DH_INTERNAL_OPTIONS. This way, -p can be specified |