perl: switch from backticks to qx()

To make it easier to find external command invocation in the source.

Also drop backticks from a comment.

To find external command invocations in Perl code use:
```sh
git grep -E "((exec|qx|open2|open3|system)\(|open\(.+-\|)" $(<perlfiles>)
```

Refs:
https://perldoc.perl.org/functions/qx
https://perldoc.perl.org/perlop#Simpler-Quote-Like-Operators

Closes #21994
This commit is contained in:
Viktor Szakats 2026-05-19 17:41:07 +02:00
parent c61f007a73
commit 9972f700a8
No known key found for this signature in database
17 changed files with 48 additions and 48 deletions

View file

@ -136,7 +136,7 @@ sub pidexists {
} else {
my $filter = "PID eq $pid";
# https://ss64.com/nt/tasklist.html
my $result = `tasklist -fi \"$filter\" 2>$dev_null`;
my $result = qx(tasklist -fi \"$filter\" 2>$dev_null);
if(index($result, $pid) != -1) {
return -$pid;
}
@ -170,12 +170,12 @@ sub pidterm {
Win32::Process::KillProcess($pid, 0);
} else {
# https://ss64.com/nt/tasklist.html
my $result = `tasklist -v -fo list -fi "PID eq $pid" 2>&1`;
my $result = qx(tasklist -v -fo list -fi "PID eq $pid" 2>&1);
$result =~ s/\r//g;
$result =~ s/\n/ | /g;
print "Task info for $pid before taskkill: '$result'\n";
$result = `powershell -Command "Get-CimInstance -ClassName Win32_Process -Filter 'ParentProcessId=$pid' | Select ProcessId,ParentProcessId,Name,CommandLine"`;
$result = qx(powershell -Command "Get-CimInstance -ClassName Win32_Process -Filter 'ParentProcessId=$pid' | Select ProcessId,ParentProcessId,Name,CommandLine");
$result =~ s/\r//g;
print "Task child processes for $pid before taskkill:\n";
print "$result\n";
@ -221,12 +221,12 @@ sub pidkill {
Win32::Process::KillProcess($pid, 0);
} else {
# https://ss64.com/nt/tasklist.html
my $result = `tasklist -v -fo list -fi "PID eq $pid" 2>&1`;
my $result = qx(tasklist -v -fo list -fi "PID eq $pid" 2>&1);
$result =~ s/\r//g;
$result =~ s/\n/ | /g;
print "Task info for $pid before taskkill: '$result'\n";
$result = `powershell -Command "Get-CimInstance -ClassName Win32_Process -Filter 'ParentProcessId=$pid' | Select ProcessId,ParentProcessId,Name,CommandLine"`;
$result = qx(powershell -Command "Get-CimInstance -ClassName Win32_Process -Filter 'ParentProcessId=$pid' | Select ProcessId,ParentProcessId,Name,CommandLine");
$result =~ s/\r//g;
print "Task child processes for $pid before taskkill:\n";
print "$result\n";