Skip to content

shellwords only parses lines that are defined #1

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

d-lamb
Copy link

@d-lamb d-lamb commented Aug 24, 2022

Using perl 5.34.1 on MacOS with perl provided by Macports, the following produces a warning:

perl -MText::ParseWords -MDevel::CheckLib -E 'say $]; say Text::ParseWords->VERSION; say Devel::CheckLib->VERSION;'
Use of uninitialized value $line in substitution (s///) at /opt/local/lib/perl5/vendor_perl/5.34/Text/ParseWords.pm line 21.
5.034001
3.31
1.16

It's possible many modules (like Devel::CheckLib here) will accidentally call shellwords with an undefined value. The PR suppresses that warning by only doing the substitution if $line is defined in ParseWords.pm line 21.

I wanted to include a test in ParseWords.t, something like this:

eval {
    use warnings FATAL => qw(uninitialized);
    shellwords("a b c",undef,"d e f");
};
is($@,'','did not die on shellwords undef');

but I could not get make test to fail with the existing unpatched code. Perhaps you have a better idea.

Avoids a warning from this module.
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

Successfully merging this pull request may close these issues.

1 participant