testcurl.pl: replace shell commands with Perl rmtree()

Ref: https://perldoc.perl.org/5.8.2/File::Path
Follow-up to e992aa6a54

Closes #21053
This commit is contained in:
Viktor Szakats 2026-03-21 19:36:10 +01:00
parent e2186933c1
commit 3025c9778a
No known key found for this signature in database

View file

@ -64,6 +64,7 @@ use strict;
use warnings;
use Cwd;
use File::Path;
use File::Spec;
# Turn on warnings (equivalent to -w, which cannot be used with /usr/bin/env)
@ -185,18 +186,6 @@ $ENV{LC_ALL}="C" if(($ENV{LC_ALL}) && ($ENV{LC_ALL} !~ /^C$/));
$ENV{LC_CTYPE}="C" if(($ENV{LC_CTYPE}) && ($ENV{LC_CTYPE} !~ /^C$/));
$ENV{LANG}="C";
sub rmtree($) {
my $target = $_[0];
if($^O eq 'MSWin32') {
foreach (glob($target)) {
s:/:\\:g;
system('rd', ('/s', '/q', $_));
}
} else {
system('rm', ('-rf', $target));
}
}
sub grepfile($$) {
my ($target, $fn) = @_;
open(my $fh, "<", $fn) or die;
@ -392,8 +381,8 @@ $buildlogname="buildlog-$$";
$buildlog="$pwd/$buildlogname";
# remove any previous left-overs
rmtree "build-*";
rmtree "buildlog-*";
foreach(glob("build-*")) { rmtree $_; }
foreach(glob("buildlog-*")) { rmtree $_; }
# this is to remove old build logs that ended up in the wrong dir
foreach(glob("$CURLDIR/buildlog-*")) { unlink $_; }