3 # Because the getopt() program is so horribly broken, I wrote my own argument
4 # processer that uses the find Getopt::Long module. This is used by all
5 # debhelper shell scripts.
7 # Joey Hess, GPL copyright 1998.
9 BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
13 # This is a tricky (and nasty) bit: override the error() function, which
14 # comes from Dh_Lib, with one of our own so we print out the list of errors
15 # to the shell, which can do what it wants with them.
16 sub Dh_Getopt::error { my $message=shift;
17 print "DH_PARSE_ERROR='$message'\n";
22 my %options=Dh_Getopt::parseopts();
24 # Change a few lists in %options into strings,
25 # generate some options that only need to be visible to the
26 # shell scripts so Dh_Getopt doesn't bother generating.
27 $options{DOPACKAGES}=join " ",@{$options{DOPACKAGES}};
28 if ($#{$options{EXCLUDE}} > -1) {
29 $options{EXCLUDE_GREP}=join '|', @{$options{EXCLUDE}};
31 $options{EXCLUDE}=join " ",@{$options{EXCLUDE}};
33 # Check to see if DH_VERBOSE environment variable was set, if so,
34 # make sure verbose is on.
35 if (defined $main::ENV{DH_VERBOSE}) {
36 if ($main::ENV{DH_VERBOSE} ne undef) {
41 # Check to see if DH_NO_ACT environment variable was set, if so,
42 # make sure no act mode is on.
43 if (defined $main::ENV{DH_NO_ACT}) {
44 if ($main::ENV{DH_NO_ACT} ne undef) {
49 # Now output everything, in a format suitable for a shell to eval it.
50 foreach (keys(%options)) {
51 if (defined $options{$_}) {
52 print "DH_$_='$options{$_}'\n";
56 # This sets $@ in the shell to whatever arguements remain.
57 print "set -- @ARGV\n"