houseabsolute / perl-code-tidyall

Engine for tidyall, your all-in-one code tidier and validator
https://metacpan.org/release/Code-TidyAll/
Other
21 stars 31 forks source link

-i/-I options conflict because Getopt::Long is case insensitive by default #125

Closed mauke closed 10 months ago

mauke commented 11 months ago

bin/tidyall does

    'i|ignore=s@'     => \$params{ignore},
...
    'I=s'             => \$inc_dirs,

But that doesn't work in Getopt::Long with default settings: https://metacpan.org/pod/Getopt::Long#Getting-Started-with-Getopt::Long

In the default configuration, options names may be abbreviated to uniqueness, case does not matter, and a single dash is sufficient, even for long option names.

Since case is ignored by default, the two option specifications clash and only one can be used.

To fix this, you should either enable bundling using use Getopt::Long qw(:config bundling)

When configured for bundling, single-character options are matched case sensitive while long options are matched case insensitive.

or enable case sensitive mode using use Getopt::Long qw(:config no_ignore_case).

Getopt::Long has started detecting this bug in version 2.55: https://metacpan.org/dist/Getopt-Long/changes

  • Fix long standing bug that duplicate options were not detected when the options differ in case while ignore_case is in effect. This will now yield a warning and become a fatal error in a future release.

... which causes test failures in Code::TidyAll if Getopt::Long is new enough.