Subject: | Can undef be left alone, especially in blank arrays without any elements? |
Date: | Fri, 10 Jun 2016 11:25:33 -0700 |
To: | bug-String-ShellQuote [...] rt.cpan.org |
From: | smu johnson <smujohnson [...] gmail.com> |
Hi,
This isn't really a "bug report" since it's possible that this happens on
purpose, but ShellQuote will treat undefs as blank strings. I first
noticed this when I shell_quote'd an @ARGV that was empty -- and the result
ended up being an array with 1 value of ''. In this case using the array
will behave differently than its source if its size is checked during if
statements, foreach's, etc.
Put simply: an array of 0 elements will return an array of size 1.
Of course, I can easily get around it by checking the source array first
(and not even bothering to shell_quote() it if it's blank) but some of me
wonders if the behaviour of ShellQuote would be better to leave undef
scalars as undefs, and blank arrays as blank arrays with a size of 0 /
unchanged.
Thanks for reading! Version info below:
---------------------------------------------------------
sjohnson@pinky:~$ perl -v | lg 2
This is perl 5, version 18, subversion 2 (v5.18.2) built for
x86_64-linux-gnu-thread-multi
sjohnson@pinky:~$ perlmodver String::ShellQuote
String::ShellQuote: 1.04
sjohnson@pinky:~$ uname -a
Linux pinky 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20
UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
--
smu johnson <smujohnson@gmail.com>