Commit | Line | Data |
---|---|---|
01e8c204 | 1 | # newgetopt.pl -- new options parsing. |
2 | # Now just a wrapper around the Getopt::Long module. | |
9a24ba61 | 3 | # $Id: newgetopt.pl,v 1.17 1996-10-02 11:17:16+02 jv Exp $ |
352d5a3a | 4 | |
ee0007ab | 5 | { package newgetopt; |
ee0007ab | 6 | |
01e8c204 | 7 | # Values for $order. See GNU getopt.c for details. |
8 | $REQUIRE_ORDER = 0; | |
9 | $PERMUTE = 1; | |
10 | $RETURN_IN_ORDER = 2; | |
11 | ||
12 | # Handle POSIX compliancy. | |
13 | if ( defined $ENV{"POSIXLY_CORRECT"} ) { | |
14 | $autoabbrev = 0; # no automatic abbrev of options (???) | |
15 | $getopt_compat = 0; # disallow '+' to start options | |
16 | $option_start = "(--|-)"; | |
17 | $order = $REQUIRE_ORDER; | |
01d0d956 | 18 | $bundling = 0; |
9a24ba61 | 19 | $passthrough = 0; |
ee0007ab | 20 | } |
01e8c204 | 21 | else { |
22 | $autoabbrev = 1; # automatic abbrev of options | |
23 | $getopt_compat = 1; # allow '+' to start options | |
24 | $option_start = "(--|-|\\+)"; | |
25 | $order = $PERMUTE; | |
01d0d956 | 26 | $bundling = 0; |
9a24ba61 | 27 | $passthrough = 0; |
ee0007ab LW |
28 | } |
29 | ||
01e8c204 | 30 | # Other configurable settings. |
31 | $debug = 0; # for debugging | |
32 | $ignorecase = 1; # ignore case when matching options | |
33 | $argv_end = "--"; # don't change this! | |
34 | } | |
352d5a3a | 35 | |
01e8c204 | 36 | use Getopt::Long; |
352d5a3a | 37 | |
01e8c204 | 38 | ################ Subroutines ################ |
352d5a3a | 39 | |
01e8c204 | 40 | sub NGetOpt { |
352d5a3a | 41 | |
01e8c204 | 42 | $Getopt::Long::debug = $newgetopt::debug |
43 | if defined $newgetopt::debug; | |
44 | $Getopt::Long::autoabbrev = $newgetopt::autoabbrev | |
45 | if defined $newgetopt::autoabbrev; | |
46 | $Getopt::Long::getopt_compat = $newgetopt::getopt_compat | |
47 | if defined $newgetopt::getopt_compat; | |
48 | $Getopt::Long::option_start = $newgetopt::option_start | |
49 | if defined $newgetopt::option_start; | |
50 | $Getopt::Long::order = $newgetopt::order | |
51 | if defined $newgetopt::order; | |
01d0d956 | 52 | $Getopt::Long::bundling = $newgetopt::bundling |
53 | if defined $newgetopt::bundling; | |
01e8c204 | 54 | $Getopt::Long::ignorecase = $newgetopt::ignorecase |
55 | if defined $newgetopt::ignorecase; | |
9a24ba61 | 56 | $Getopt::Long::ignorecase = $newgetopt::ignorecase |
57 | if defined $newgetopt::ignorecase; | |
58 | $Getopt::Long::passthrough = $newgetopt::passthrough | |
59 | if defined $newgetopt::passthrough; | |
01e8c204 | 60 | |
61 | &GetOptions; | |
62 | } | |
352d5a3a | 63 | |
01e8c204 | 64 | ################ Package return ################ |
352d5a3a | 65 | |
352d5a3a | 66 | 1; |
01e8c204 | 67 | |
68 | ################ End of newgetopt.pl ################ |