You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This bit of code in the _options_fix_argv routine of MooX::Options::Role strips leading and trailing quotes:
#remove the quoted if exist to chain
$_[0] =~ s/^['"]|['"]$//gx;
This is a problem when you want to preserve those quotes. A small example:
#!/usr/bin/env perl
package Test;
use Moo;
use MooX::Options;
option test => (
is => 'ro',
short => 't',
format => 's',
);
1;
package main;
my $t = Test->new_with_options;
print $t->test."\n";
Run the above:
./test.pl -t "This is 'a test'"
This is 'a test
When I would expect to see
This is 'a test'
as its output.
The text was updated successfully, but these errors were encountered:
I tried commenting that line out and it causes some test failures. It looks like it's also related to the autorange feature.
This test is one of two that fail (from t/base.st line 626):
{
local @ARGV = ( '-r=1', '-r="2,3"', '-r=4' );
my $t = rg_str_short->new_with_options();
is_deeply( $t->range_str, [ '1', "2,3", '4' ], 'str7 req is ok' );
}
Maybe the code that strips quotes should only run when autorange is set? something like this:
--- a/lib/MooX/Options/Role.pm
+++ b/lib/MooX/Options/Role.pm
@@ -174,9 +174,9 @@ sub _options_fix_argv {
my $autorange = $option_data->{$original_long_option}{autorange};
my $argv_processor = sub {
- #remove the quoted if exist to chain
- $_[0] =~ s/^['"]|['"]$//gx;
if ($autorange) {
+ #remove the quoted if exist to chain
+ $_[0] =~ s/^['"]|['"]$//gx;
push @new_argv,
map { $arg_name => $_ } _expand_autorange( $_[0] );
}
Making that change fixes the problem I was having and passes a 'make test'. But I admit I don't really know why that code was there so my change might introduce other problems.
This bit of code in the _options_fix_argv routine of MooX::Options::Role strips leading and trailing quotes:
This is a problem when you want to preserve those quotes. A small example:
Run the above:
When I would expect to see
as its output.
The text was updated successfully, but these errors were encountered: