-
Notifications
You must be signed in to change notification settings - Fork 78
Closed
Description
When reading the unit test for the sub oneliner
from t/oneliner.t
try_oneliner(q{$PATH = 'foo'; print $PATH},[], q{foo}, 'dollar signs' );
You have the feeling that oneliner authorizes the usage of variables, all the most the test is passing.
But in truth it's using references:
# $(ABSPERLRUN) -e '$$PATH = '\''foo'\''; print $$PATH' --
I wonder if we should teach sub oneliner
to allow_variables
when calling quote_literal
, or detect incorrect usage of variable...
For example you can use %h
but then it's going to fail when using $h
later to access a value...
Detail:
my %h = (1..4);
is a valid oneliner
$mm->oneliner( q[my %h = (1..4);]);
# $(ABSPERLRUN) -e 'my %h = (1..4); print $$h[1]' --
but my %h = (1..4); print $h[1]
is invalid
$mm->oneliner( q[my %h = (1..4);]);
# $(ABSPERLRUN) -e 'my %h = (1..4); print $$h[1]' --
#!perl
use Test::More;
require ExtUtils::MM;
my $mm = MM->new(
{ NAME => q[Fake], }
);
my $cmd;
# valid - using ref
my $cmd = $mm->oneliner( q[$PATH = 'foo'; print $PATH]);
note $cmd;
# $(ABSPERLRUN) -e '$$PATH = '\''foo'\''; print $$PATH' --
# invalid
my $cmd = $mm->oneliner( q[my $PATH = 'foo'; print $PATH]);
note $cmd;
# $(ABSPERLRUN) -e 'my $$PATH = '\''foo'\''; print $$PATH' --
Metadata
Metadata
Assignees
Labels
No labels