]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
testcurl.pl: replace shell commands with Perl `rmtree()`
authorViktor Szakats <commit@vsz.me>
Sat, 21 Mar 2026 18:36:10 +0000 (19:36 +0100)
committerViktor Szakats <commit@vsz.me>
Sat, 21 Mar 2026 21:42:38 +0000 (22:42 +0100)
Ref: https://perldoc.perl.org/5.8.2/File::Path
Follow-up to e992aa6a54f87f33eafd124cf09f0f70d7d24928

Closes #21053

tests/testcurl.pl

index 198c41d8dc52d626470b0005c57d65d79267d50f..4b355510c727d52db9523829b498c127f074eb0f 100755 (executable)
@@ -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 $_; }