on platforms like HP-UX that are subject to the ARG_ZERO_IS_SCRIPT
hack, $^X was improperly set to the script name when the script
was run via the PATH; argv[0] in that case shows up as the bare
name of the script rather than its fully qualified path, which
meant that the sanity check in the ARG_ZERO_IS_SCRIPT code fails
to recognize it as the running script name; fix tries to match
bare script name in that case (from Gisle Aas)
tweak change#17421 ($0 is full path to script even when script
is invoked via PATH almost everywhere except Windows)
p4raw-link: @17421 on //depot/maint-5.6/perl:
32099b6ba13a228ffd08d5c7359d07c687b11471
p4raw-id: //depot/perl@17425
p4raw-integrated: from //depot/maint-5.6/perl@17423 'edit in'
t/op/magic.t (@17421..) 'merge in' toke.c (@16508..)
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
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 */