scripts: harden / tidy up more Perl system() calls

Closes #21007
This commit is contained in:
Viktor Szakats 2026-03-19 12:19:04 +01:00
parent 31add10322
commit 51f813308e
No known key found for this signature in database
10 changed files with 22 additions and 22 deletions

View File

@ -135,4 +135,4 @@ foreach my $v (keys %remove) {
}
# return the exit code from diff
exit system("diff -u /tmp/autotools /tmp/cmake") >> 8;
exit system('diff', ('-u', '/tmp/autotools', '/tmp/cmake')) >> 8;

View File

@ -37,12 +37,12 @@ if(!@files || $files[0] eq "-h") {
}
sub testcompile {
my $rc = system("gcc -c test.c -I include -W -Wall -pedantic -Werror -Wno-unused-parameter -Wno-unused-but-set-variable -DCURL_ALLOW_OLD_MULTI_SOCKET -DCURL_DISABLE_DEPRECATION") >> 8;
my $rc = system('gcc -c test.c -I include -W -Wall -pedantic -Werror -Wno-unused-parameter -Wno-unused-but-set-variable -DCURL_ALLOW_OLD_MULTI_SOCKET -DCURL_DISABLE_DEPRECATION') >> 8;
return $rc;
}
sub checksrc {
my $rc = system("$check test.c") >> 8;
my $rc = system($check, ('test.c')) >> 8;
return $rc;
}

View File

@ -35,7 +35,7 @@ if(!@files || $files[0] eq "-h") {
}
sub testcompile {
my $rc = system("gcc -c test.c -I include -W -Wall -pedantic -Werror -DCURL_ALLOW_OLD_MULTI_SOCKET -DCURL_DISABLE_TYPECHECK") >> 8;
my $rc = system('gcc -c test.c -I include -W -Wall -pedantic -Werror -DCURL_ALLOW_OLD_MULTI_SOCKET -DCURL_DISABLE_TYPECHECK') >> 8;
return $rc;
}

View File

@ -38,7 +38,7 @@ sub convert {
my $nroff = "$cd";
$nroff =~ s/\.md\z/.3/;
print "$dir/$cd = $dir/$nroff\n";
system("./scripts/cd2nroff -d $dir $dir/$cd");
system('./scripts/cd2nroff', ('-d', $dir, "$dir/$cd"));
}
}

View File

@ -53,31 +53,31 @@ do {
my $num = rand(scalar(@disable) - 2) + 2;
my $c = 0;
my $arg;
my @arg;
for my $d (shuffle @disable) {
$arg .= " $d";
push @arg, $d;
if(++$c >= $num) {
last;
}
}
my @stls = shuffle @tls;
$arg.= " ".$stls[0];
push @arg, @stls;
system("make clean");
if(system("./configure $arg")) {
system('make', ('clean'));
if(system('./configure', @arg)) {
print STDERR "configure problem\n";
print STDERR "./configure $arg\n";
print STDERR "./configure " . join(' ', @arg) . "\n";
exit 1;
}
if(system("make -sj10")) {
if(system('make', ('-sj10'))) {
print STDERR "Build problem\n";
print STDERR "./configure $arg\n";
print STDERR "./configure " . join(' ', @arg) . "\n";
exit 1;
}
if(system("./src/curl -V 2>/dev/null")) {
print STDERR "Running problem\n";
print STDERR "./configure $arg\n";
print STDERR "./configure " . join(' ', @arg) . "\n";
exit 1;
}
} while(1);

View File

@ -97,7 +97,7 @@ sub eol_detect {
my $issues = 0;
open(my $git_ls_files, '-|', 'git ls-files') or die "Failed running git ls-files: $!";
open(my $git_ls_files, '-|', 'git', 'ls-files') or die "Failed running git ls-files: $!";
while(my $filename = <$git_ls_files>) {
chomp $filename;

View File

@ -72,7 +72,7 @@ if(!$CAPREFIX) {
}
print "$OPENSSL\n";
system("$OPENSSL version");
system($OPENSSL, ('version'));
$PREFIX = $CAPREFIX;
$DURATION = 6000;

View File

@ -76,7 +76,7 @@ if($ARGV[0] eq "prepare") {
utime time, timegm(0,0,12,31,11,100), "rofile.txt";
chmod 0444, "rofile.txt";
if($^O eq 'cygwin') {
system "chattr +r rofile.txt";
system('chattr', ('+r', 'rofile.txt'));
}
exit 0;
@ -86,7 +86,7 @@ elsif($ARGV[0] eq "postprocess") {
# Clean up the test directory
if($^O eq 'cygwin') {
system "chattr -r $dirname/rofile.txt";
system('chattr', ('-r', "$dirname/rofile.txt"));
}
chmod 0666, "$dirname/rofile.txt";
unlink "$dirname/rofile.txt";

View File

@ -811,7 +811,7 @@ if($error) {
#***************************************************************************
# Verify that sshd actually supports our generated configuration file
#
if(system "\"$sshd\" -t -f $sshdconfig_abs > $sshdlog 2>&1") {
if(system("\"$sshd\" -t -f $sshdconfig_abs > $sshdlog 2>&1")) {
logmsg "sshd configuration file $sshdconfig failed verification\n";
display_sshdlog();
display_sshdconfig();

View File

@ -190,10 +190,10 @@ sub rmtree($) {
if($^O eq 'MSWin32') {
foreach (glob($target)) {
s:/:\\:g;
system("rd /s /q $_");
system('rd', ('/s', '/q', $_));
}
} else {
system("rm -rf $target");
system('rm', ('-rf', $target));
}
}
@ -568,7 +568,7 @@ if($configurebuild) {
} else {
logit "copying files to build directory ...";
if($^O eq 'MSWin32') {
system("xcopy /s /q \"$CURLDIR\" .");
system('xcopy', ('/s', '/q', $CURLDIR, '.'));
}
}