Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An option of [''] causes an "undefined warning" #37

Open
djerius opened this issue Jun 29, 2021 · 0 comments
Open

An option of [''] causes an "undefined warning" #37

djerius opened this issue Jun 29, 2021 · 0 comments

Comments

@djerius
Copy link
Contributor

djerius commented Jun 29, 2021

Version 0.109.

% perl -MGetopt::Long::Descriptive -E "describe_options( '%o', [''] )"                            
Use of uninitialized value $opt in lc at [...]/Getopt/Long/Descriptive.pm line 533.

This flows from the _expand subroutine, line 326

    316 sub _expand {
    317   my @expanded;
    318 
    319   for my $opt (@_) {
    320     push @expanded, {
    321       spec       => $opt->[0] || '',
    322       desc       => @$opt > 1 ? $opt->[1] : 'spacer',                                            
    323       constraint => $opt->[2] || {},
    324 
    325       # if @$_ is 0 then we got [], a spacer
    326       name       => @$opt ? _munge((split /[:=|!+]/, $opt->[0] || '')[0]) : '',                  
    327     };
    328   }

Namely,

%  perl -E 'say ( defined( (split /[:=|!+]/, "")[0] ) ? "defined" : "undef") '                    
undef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant