summaryrefslogtreecommitdiff
path: root/Debian/Debhelper/Dh_Lib.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-12-14 22:13:32 -0500
committerJoey Hess <joey@kodama.kitenet.net>2008-12-14 22:13:32 -0500
commite90eebf73099da05ffb1d1e2be30a2eccafd153c (patch)
treecffd293f81abaa33eec275e289accec550a5f5df /Debian/Debhelper/Dh_Lib.pm
parenta0fc3f57b576cd7c88a698330233df26ff13137f (diff)
Ignore unknown options in DH_OPTIONS. Debhelper will always ignore such options, even when unknown command-line options are converted back to an error. This allows (ab)using DH_OPTIONS to pass command-specific options. (Note that getopt will warn about such unknown options. Eliminating this warning without reimplementing much of Getopt::Long wasn't practical.)
Diffstat (limited to 'Debian/Debhelper/Dh_Lib.pm')
-rw-r--r--Debian/Debhelper/Dh_Lib.pm26
1 files changed, 6 insertions, 20 deletions
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 82efc5b..4df64c8 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -22,28 +22,14 @@ my $max_compat=7;
sub init {
my %params=@_;
- # If DH_OPTIONS is set, prepend it @ARGV.
- if (defined($ENV{DH_OPTIONS})) {
- # Ignore leading/trailing whitespace.
- $ENV{DH_OPTIONS}=~s/^\s+//;
- $ENV{DH_OPTIONS}=~s/\s+$//;
- unshift @ARGV,split(/\s+/,$ENV{DH_OPTIONS});
- }
-
- # Check to see if an argument on the command line starts with a dash.
- # if so, we need to pass this off to the resource intensive
+ # Check to see if an option line starts with a dash,
+ # or DH_OPTIONS is set.
+ # If so, we need to pass this off to the resource intensive
# Getopt::Long, which I'd prefer to avoid loading at all if possible.
- my $parseopt=undef;
- my $arg;
- foreach $arg (@ARGV) {
- if ($arg=~m/^-/) {
- $parseopt=1;
- last;
- }
- }
- if ($parseopt) {
+ if ((defined $ENV{DH_OPTIONS} && length $ENV{DH_OPTIONS}) ||
+ grep /^-/, @ARGV) {
eval "use Debian::Debhelper::Dh_Getopt";
- error($!) if $@;
+ error($@) if $@;
Debian::Debhelper::Dh_Getopt::parseopts($params{options});
}