Skip Menu |

This queue is for tickets about the Getopt-Long CPAN distribution.

Report information
The Basics
Id: 128965
Status: resolved
Priority: 0/
Queue: Getopt-Long

People
Owner: jv [...] cpan.org
Requestors: jim.avera [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 2.51



Subject: bundling_values disables single-hyphen options (?)
Date: Sat, 30 Mar 2019 10:30:29 -0700
To: bug-Getopt-Long [...] rt.cpan.org
From: Jim Avera <jim.avera [...] gmail.com>
Not sure, but it seems like "bundling_values" makes single-hyphen options stop working: #!/usr/bin/perl use strict; use warnings; use v5.10; use Getopt::Long qw(GetOptions); my @Idirs; @ARGV = ("-I", "/somedir", "foo","bar"); Getopt::Long::Configure("default", "bundling_values"); GetOptions( "I=s" => \@Idirs,) || die; # dies with "Unknown option: I" say "Idirs=@Idirs ARGV=@ARGV";
Actually the problem seems to be case sensitivity. When you specify GetOptions( "i=s" => \@Idirs) ... (lowercase i) it works as it should. Do you have a compelling reason to use bundling_values?
Subject: Re: [rt.cpan.org #128965] bundling_values disables single-hyphen options (?)
Date: Sat, 30 Mar 2019 17:45:27 -0700
To: bug-Getopt-Long [...] rt.cpan.org
From: Jim Avera <jim.avera [...] gmail.com>
And -i for something different. On Sat, Mar 30, 2019, 5:44 PM Jim Avera <jim.avera@gmail.com> wrote: Show quoted text
> I want to have a -I option similar to the the perl executable, so -I/dir > (no space) works. But don't want full bundling eg -vax. > > On Sat, Mar 30, 2019, 12:46 PM Johan Vromans via RT < > bug-Getopt-Long@rt.cpan.org> wrote: >
>> <URL: https://rt.cpan.org/Ticket/Display.html?id=128965 > >> >> Actually the problem seems to be case sensitivity. When you specify >> >> GetOptions( "i=s" => \@Idirs) ... >> >> (lowercase i) it works as it should. >> >> Do you have a compelling reason to use bundling_values? >>
>
Subject: Re: [rt.cpan.org #128965] bundling_values disables single-hyphen options (?)
Date: Sat, 30 Mar 2019 17:44:18 -0700
To: bug-Getopt-Long [...] rt.cpan.org
From: Jim Avera <jim.avera [...] gmail.com>
I want to have a -I option similar to the the perl executable, so -I/dir (no space) works. But don't want full bundling eg -vax. On Sat, Mar 30, 2019, 12:46 PM Johan Vromans via RT < bug-Getopt-Long@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=128965 > > > Actually the problem seems to be case sensitivity. When you specify > > GetOptions( "i=s" => \@Idirs) ... > > (lowercase i) it works as it should. > > Do you have a compelling reason to use bundling_values? >
Subject: Re: [rt.cpan.org #128965] Resolved: bundling_values disables single-hyphen options (?)
Date: Wed, 14 Aug 2019 12:56:06 -0700
To: bug-Getopt-Long [...] rt.cpan.org
From: Jim Avera <jim.avera [...] gmail.com>
On 8/13/19 10:21 AM, Johan Vromans via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=128965 > > > According to our records, your request has been resolved. If you have any > further questions or concerns, please respond to this message.
Hi,   Could you explain the resolution a bit more (I don't understand why this isn't a bug). Can you give Perl code which allows parsing "-I/some/dir" (upper-case -I, no space)? Thanks.
Getopt::Long::Configure( qw( no_ignorecase bundling ) ); @ARGV = ( "-I/foo/var" ); GetOptions( "I=s" );
On Thu Aug 15 04:14:31 2019, JV wrote: Show quoted text
> Getopt::Long::Configure( qw( no_ignorecase bundling ) ); > @ARGV = ( "-I/foo/var" ); > GetOptions( "I=s" );
I still think this is a bug. First of all, "no_ignorecase" is not documented, and the positive form, per the pod, is "ignore_case". Users can't be expected to know to use the non-analogous "no_ignorecase". So either the code or the docs should be adjusted so they correspond. But more importantly, the pod says: "When configured for bundling, single-character options are matched case sensitive while long options are matched case insensitive." Doesn't that mean that -I (a single-character option) should be matched case sensitively by default (with "bundling")?
All configure options take a "no" (or "no_") prefix to inverse the action. I'll change the wording in the doc to make this more clear: "This subroutine takes a list of quoted strings, each specifying a configuration option to be enabled, e.g. C<ignore_case>. To disable, prefix with C<no> or C<no_>, e.g. C<no_ignore_case>." In the case at hand no_ignore_case is not necessary since it is implied by bundling. The example becomes: Getopt::Long::Configure( qw( bundling ) ); @ARGV = ( "-I/foo/var", "-i" ); GetOptions( "I=s", "i" ); Does this solve the issues?
On Fri Aug 16 02:13:56 2019, JV wrote: Show quoted text
> In the case at hand no_ignore_case is not necessary since it is > implied by bundling. The example becomes: > > Getopt::Long::Configure( qw( bundling ) ); > @ARGV = ( "-I/foo/var", "-i" ); > GetOptions( "I=s", "i" ); > > Does this solve the issues?
I'm sorry to have muddied the conversation by saying "bundling" instead of "bundling_values" in my last comment. The point (see the original post) is that with *bundling_values*, an option -I never works, whether or not bundled with a value. From your comments this has something to do with case-sensitive parsing, which seemed to me to be contrary to the docs. But EVEN IF case-sensitive parsing were expected, there is no case-mismatch involved, that is "I" matches "I" (there is no "i" involved). Here is an even simpler test case: Getopt::Long::Configure("bundling_values"); @ARGV=("-I"); GetOptions( "I" => sub{say "Got @_"} ) || die; # "Unknown option: I" I still don't understand how this can be correct behavior. Regarding case-sensitivity, the docs say "When configured for bundling...[single-char options are matched case-sensitive]". It is _intentional_ that this does not cover the case of bundling_override?
Definitely not! But there are too many internal options that slightly influence each other and I do not feel like poking in that can of worms. Just don't use bundling_values without no_ignorecase. Better still, don't use bundling_values if bundling will do. Sorry for the inconvenience. I tried several ways to fix this bug every fix caused other regression tests to fail...
On Sat Aug 17 16:19:21 2019, JV wrote: Show quoted text
> Just don't use bundling_values without no_ignorecase
Ok, that's clear. Suggest mentioning this in the docs.