Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: khali [...] linux-fr.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 2.34
Fixed in: (no value)



Subject: Parsing bug for options with optional hash values
This is perl, v5.8.7 built for i486-linux When using an option with an optional hash value, values (not keys) starting with a dash trigger an unexpected error: # perl -MGetopt::Long -we "GetOptions('replace:s%');" -- --replace a=-b Unknown option: b # I attach a proposed patch, it fixes the case above but I don't really understand all the tests in this block so it might not be correct.
Subject: getopt-long-optional-hash-value-fix.patch
--- 5.8.7/Getopt/Long.pm.backup 2005-07-13 21:13:31.000000000 +0200 +++ 5.8.7/Getopt/Long.pm 2006-05-23 14:27:19.000000000 +0200 @@ -999,6 +999,10 @@ # A mandatory string takes anything. return (1, $opt, $ctl, $arg, $key) if $mand; + # Same for optional string as a hash value + return (1, $opt, $ctl, $arg, $key) + if $ctl->[CTL_DEST] == CTL_DEST_HASH; + # An optional string takes almost anything. return (1, $opt, $ctl, $arg, $key) if defined $optarg || defined $rest;
CC: khali [...] linux-fr.org
Subject: Re: [rt.cpan.org #19432] Parsing bug for options with optional hash values
Date: Tue, 23 May 2006 15:07:02 +0200
To: bug-Getopt-Long [...] rt.cpan.org
From: Johan Vromans <jvromans [...] squirrel.nl>
[Quoting Guest via RT, on May 23 2006, 08:33, in "[rt.cpan.org #19432]"] Show quoted text
> I attach a proposed patch, it fixes the case above but I don't really > understand all the tests in this block so it might not be correct.
Looks okay to me. At least, it passes all 1256 regression tests... Your fix will be in 2.35_02, and scheduled for 2.36. Thanks, Johan