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" }
12 # This is a tricky (and nasty) bit: override the error() function, which
13 # comes from Dh_Lib, with one of our own so we print out the list of errors
14 # to the shell, which can do what it wants with them.
15 sub Dh_Getopt::error { my $message=shift;
16 print "DH_PARSE_ERROR='$message'\n";
21 %options=Dh_Getopt::parseopts();
23 # Change a few lists in %options into strings,
24 # generate some options that only need to be visible to the
25 # shell scripts so Dh_Getopt doesn't bother generating.
26 $options{DOPACKAGES}=join " ",@{$options{DOPACKAGES}};
27 if ($#{$options{EXCLUDE}} > -1) {
28 $options{EXCLUDE_GREP}=join '|', @{$options{EXCLUDE}};
29 foreach (@{$options{EXCLUDE}}) {
30 $options{EXCLUDE_FIND}.="-regex .*".quotemeta($_).".* -or ";
32 $options{EXCLUDE_FIND}=~s/ -or $//;
34 $options{EXCLUDE}=join " ",@{$options{EXCLUDE}};
36 # Now output everything, in a format suitable for a shell to eval it.
37 foreach (keys(%options)) { print "DH_$_='$options{$_}'\n" };
39 # This sets $@ in the shell to whatever arguements remain.
40 print "set -- @ARGV\n"