diff options
-rwxr-xr-x | t/op/magic.t | 13 | ||||
-rw-r--r-- | toke.c | 13 |
2 files changed, 25 insertions, 1 deletions
diff --git a/t/op/magic.t b/t/op/magic.t index 436e253ee2..ab0544ef60 100755 --- a/t/op/magic.t +++ b/t/op/magic.t @@ -226,7 +226,18 @@ EOF s/\.exe//i if $Is_Dos or $Is_os2; s{\\}{/}g; ok((($Is_MSWin32 || $Is_os2) ? uc($_) eq uc($s1) : $_ eq $s1), " :$_:!=:$s1: after `$perl $script`"); - ok unlink($script), $!; + + local $ENV{PATH}= "."; + (my $script_name = $script) =~ s/.*(show-shebang)/$1/; + $s1 = "\$^X is $perl, \$0 is $script_name\n" if $Is_MSWin32; + $_ = `$script_name`; + s/\.exe//i if $Is_Dos or $Is_Cygwin or $Is_os2; + s{\bminiperl\b}{perl}; # so that test doesn't fail with miniperl + s{is perl}{is $perl}; # for systems where $^X is only a basename + s{\\}{/}g; + ok((($Is_MSWin32 || $Is_os2) ? uc($_) eq uc($s1) : $_ eq $s1), " :$_:!=:$s1:"); + + unlink($script) || die "unlink($script): $!"; } # $], $^O, $^T @@ -2614,6 +2614,19 @@ Perl_yylex(pTHX) sv_setpvn(x, ipath, ipathend - ipath); SvSETMAGIC(x); } + else { + STRLEN blen; + STRLEN llen; + char *bstart = SvPV(CopFILESV(PL_curcop),blen); + char *lstart = SvPV(x,llen); + if (llen < blen) { + bstart += blen - llen; + if (strnEQ(bstart, lstart, llen) && bstart[-1] == '/') { + sv_setpvn(x, ipath, ipathend - ipath); + SvSETMAGIC(x); + } + } + } TAINT_NOT; /* $^X is always tainted, but that's OK */ } #endif /* ARG_ZERO_IS_SCRIPT */ |