develooper Front page | perl.perl5.porters | Postings from January 2017

[perl #130626] Getopt::Long fails to call sub action if optionalvalue is omitted

Thread Next
From:
James E Keenan via RT
Date:
January 23, 2017 12:20
Subject:
[perl #130626] Getopt::Long fails to call sub action if optionalvalue is omitted
Message ID:
rt-4.0.24-6357-1485174006-541.130626-15-0@perl.org
On Mon, 23 Jan 2017 06:04:36 GMT, jim.avera@gmail.com wrote:
> 
> This is a bug report for perl from jim.avera@gmail.com,
> generated with the help of perlbug 1.40 running under perl 5.22.1.
> 
> -----------------------------------------------------------------
> Under "gnu_compat", if an optional-value option is defined,
> for example
>    "color:s" => sub{...}
> and the option is given without a value, then the action sub is
> never called and the option is silently swallowed, i.e., lost.
> 
> #!/usr/bin/perl
> use strict; use warnings;
> use Getopt::Long qw(GetOptions);
> 
> @ARGV = ('--maybe');
> 
> warn "ORIGINAL ARGV=(@ARGV)\n";
> 
> Getopt::Long::Configure("gnu_compat");
> GetOptions(
>   "maybe:s"  => sub{ die "maybe sub called" }, # never called
> );
> 
> warn "FINAL ARGV=(@ARGV)\n";  # empty
> 
> 

Getopt-Long is maintained upstream on CPAN.  Please report this at https://rt.cpan.org/Dist/Display.html?Name=Getopt-Long.

Thank you very much.


-- 
James E Keenan (jkeenan@cpan.org)

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=130626

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About