diff options
author | Yves Orton <demerphq@gmail.com> | 2023-03-19 18:42:44 +0100 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2023-03-22 02:53:47 +0800 |
commit | 8312884dcdcc6d91617ebb943c385021054627d0 (patch) | |
tree | a317b2d202137026ff61af22e6f7711f6a7121d9 /t | |
parent | 3c0bfcec550c59c81df397902a1fdea23ec37edc (diff) | |
download | perl-8312884dcdcc6d91617ebb943c385021054627d0.tar.gz |
t/TEST - glob @ARGV after we setup @INC properly (win32 only)
On win32 we glob the arguments passed into @ARGV. *However*, this was
done in an unsafe way that could result in @ARGV being empty if 'lib'
was not in @INC prior to execution. Also it was being done in an eval
STRING to avoid loading File::Glob unnecessarily, but with no error
checking of the eval.
In fact this logic was firing much too early, before option parsing, and
before @INC was set up properly.
This patch moves this logic to much later, after any options are parsed
out and after @INC is set up, which should reduce or eliminate the
chance it dies. It also reworks the logic so that if the eval does die
that the entire script dies as well.
Diffstat (limited to 't')
-rwxr-xr-x | t/TEST | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -121,12 +121,9 @@ $| = 1; # remove empty elements due to insertion of empty symbols via "''p1'" syntax @ARGV = grep($_,@ARGV) if $^O eq 'VMS'; -# String eval to avoid loading File::Glob on non-miniperl. -# (Windows only uses this script for miniperl.) -@ARGV = eval 'map glob, @ARGV' if $^O eq 'MSWin32'; - my $is_win32 = $^O eq "MSWin32"; -my $is_os2 = $^O eq "os2"; +my $is_os2 = $^O eq "os2"; + our $show_elapsed_time = $ENV{HARNESS_TIMER} || 0; @@ -160,6 +157,17 @@ if (-f 'TEST' && -f 'harness' && -d '../lib') { die "You need to run \"make test_prep\" first to set things up.\n" unless -e 'perl' or -e 'perl.exe' or -e 'perl.pm'; +if ($is_win32) { + # String eval to avoid loading File::Glob on non-miniperl. + # (Windows only uses this script for miniperl.) + my @argv; + if (eval '@argv = map glob, @ARGV; 1') { + @ARGV = @argv; + } else { + die "Failed to glob \@ARGV: $@"; + } +} + # check leakage for embedders $ENV{PERL_DESTRUCT_LEVEL} = 2 unless exists $ENV{PERL_DESTRUCT_LEVEL}; # check existence of all symbols |