perl: || die -> or die

Usage was fifty-fifty between these syntaxes before this patch.

Closes #22036
This commit is contained in:
Viktor Szakats 2026-06-15 01:26:04 +02:00
parent 5d1ac48088
commit 678e63934c
No known key found for this signature in database
29 changed files with 69 additions and 69 deletions

View file

@ -16,7 +16,7 @@ use warnings;
my @asyms;
open(S, "<./docs/libcurl/symbols-in-versions")
|| die "cannot find symbols-in-versions";
or die "cannot find symbols-in-versions";
while(<S>) {
if(/^([^ ]*) /) {
push @asyms, $1;
@ -30,7 +30,7 @@ my @aopts = (
);
open(O, "<./docs/options-in-versions")
|| die "cannot find options-in-versions";
or die "cannot find options-in-versions";
while(<O>) {
chomp;
if(/^([^ ]+)/) {
@ -50,7 +50,7 @@ while(<O>) {
close(O);
open(C, "<./.github/scripts/spellcheck.curl")
|| die "cannot find spellcheck.curl";
or die "cannot find spellcheck.curl";
while(<C>) {
if(/^\#/) {
next;

View file

@ -41,7 +41,7 @@
use strict;
use warnings;
open(S, "<../libcurl/symbols-in-versions") || die;
open(S, "<../libcurl/symbols-in-versions") or die;
my %doc;
my %rem;
@ -70,7 +70,7 @@ sub age {
}
my %used;
open(C, "<$ARGV[0]") || die;
open(C, "<$ARGV[0]") or die;
while(<C>) {
if(/\W(CURL[_A-Z0-9v]+)\W/) {

View file

@ -30,7 +30,7 @@ use warnings;
sub convert {
my ($dir) = @_;
opendir(my $dh, $dir) || die "could not open $dir";
opendir(my $dh, $dir) or die "could not open $dir";
my @cd = grep { /\.md\z/ && -f "$dir/$_" } readdir($dh);
closedir $dh;

View file

@ -13,7 +13,7 @@ use Cwd 'abs_path';
my @files;
my $is_git = 0;
if(system('git rev-parse --is-inside-work-tree >/dev/null 2>&1') == 0) {
open(O, '-|', 'git', 'ls-files', '*.[ch]') || die; push @files, <O>; close(O);
open(O, '-|', 'git', 'ls-files', '*.[ch]') or die; push @files, <O>; close(O);
$is_git = 1;
}
else {
@ -34,7 +34,7 @@ my $anyfailed = 0;
for my $dir (@dirs) {
if($is_git) {
@files = ();
open(O, '-|', 'git', 'ls-files', ":(glob)$dir/*.[ch]") || die; push @files, <O>; close(O);
open(O, '-|', 'git', 'ls-files', ":(glob)$dir/*.[ch]") or die; push @files, <O>; close(O);
chomp(@files);
}
else {

View file

@ -541,7 +541,7 @@ sub scanfile {
printf "Checking file: $file\n";
}
open(my $R, '<', $file) || die "failed to open $file";
open(my $R, '<', $file) or die "failed to open $file";
my $incomment = 0;
my @copyright = ();

View file

@ -80,21 +80,21 @@ sub parse_main_opts {
my (@files, @list);
my ($dir_handle, $file_content);
opendir($dir_handle, $opts_dir) || die "Unable to open dir: $opts_dir due to error: $!";
opendir($dir_handle, $opts_dir) or die "Unable to open dir: $opts_dir due to error: $!";
@files = readdir($dir_handle);
closedir($dir_handle) || die "Unable to close handle on dir: $opts_dir due to error: $!";
closedir($dir_handle) or die "Unable to close handle on dir: $opts_dir due to error: $!";
# We want regular files that end with .md and do not start with an underscore
# Edge case: MANPAGE.md does not start with an underscore but also is not documentation for an option
@files = grep { $_ =~ /\.md$/i && !/^_/ && -f "$opts_dir/$_" && $_ ne "MANPAGE.md" } @files;
for my $file (@files) {
open(my $doc_handle, '<', "$opts_dir/$file") || die "Unable to open file: $file due to error: $!";
open(my $doc_handle, '<', "$opts_dir/$file") or die "Unable to open file: $file due to error: $!";
$file_content = join('', <$doc_handle>);
close($doc_handle) || die "Unable to close file: $file due to error: $!";
close($doc_handle) or die "Unable to close file: $file due to error: $!";
# Extract the curldown header section demarcated by ---
$file_content =~ /^---\s*\n(.*?)\n---\s*\n/s || die "Unable to parse file $file";
$file_content =~ /^---\s*\n(.*?)\n---\s*\n/s or die "Unable to parse file $file";
$file_content = $1;
my ($short, $long, $arg, $desc);

View file

@ -35,7 +35,7 @@ my $error;
sub scanfile {
my ($file) = @_;
open(F, "<$file") || die "$file failed";
open(F, "<$file") or die "$file failed";
my $unit = 0;
my $line = 0;
my $unitref = 0;

View file

@ -1365,7 +1365,7 @@ if($ENV{'CURL_MAKETGZ_VERSION'}) {
$version = $ENV{'CURL_MAKETGZ_VERSION'};
}
else {
open(INC, "<$include/curl/curlver.h") || die "no $include/curl/curlver.h";
open(INC, "<$include/curl/curlver.h") or die "no $include/curl/curlver.h";
while(<INC>) {
if($_ =~ /^#define LIBCURL_VERSION \"([0-9.]*)/) {
$version = $1;

View file

@ -182,7 +182,7 @@ sub doublecheck {
return @also;
}
open(N, '-|', 'nm', $file) || die;
open(N, '-|', 'nm', $file) or die;
my %exist;
my %uses;

View file

@ -52,7 +52,7 @@ my $PREFIX;
sub redir {
my $outfn = shift if($_[0] =~ /^>/);
my $hideerr = shift if($_[0] =~ /^2>/);
open(my $outfd, $outfn) || die if($outfn);
open(my $outfd, $outfn) or die if($outfn);
my $pid = open3(my $in, my $out, my $err = gensym, @_);
if(!$hideerr) { while(<$err>) { print STDERR $_; }; }
if($outfn) { while(<$out>) { print $outfd $_; }; close($outfd); }

View file

@ -386,12 +386,12 @@ sub compareparts {
sub writearray {
my ($filename, $arrayref) = @_;
open(my $temp, ">", $filename) || die "Failure writing file";
open(my $temp, ">", $filename) or die "Failure writing file";
binmode($temp,":raw"); # Cygwin fix
for(@$arrayref) {
print $temp $_;
}
close($temp) || die "Failure writing file";
close($temp) or die "Failure writing file";
}
#

View file

@ -36,7 +36,7 @@ my $what = $ARGV[2];
# Read the output of curl --version
my $curl_protocols = "";
open(CURL, $ARGV[1]) || die "Cannot get curl $what list\n";
open(CURL, $ARGV[1]) or die "Cannot get curl $what list\n";
while(<CURL>) {
$curl_protocols = $_ if(/$what:/i);
}
@ -48,7 +48,7 @@ my @curl = split / /,$1;
# Read the output of curl-config
my @curl_config;
open(CURLCONFIG, '-|', 'sh', $ARGV[0], "--$what") || die "Cannot get curl-config $what list\n";
open(CURLCONFIG, '-|', 'sh', $ARGV[0], "--$what") or die "Cannot get curl-config $what list\n";
while(<CURLCONFIG>) {
chomp;
$_ = lc($_) if($what eq "protocols"); # accept uppercase protocols in curl-config

View file

@ -34,7 +34,7 @@ if($#ARGV != 2) {
my $what = $ARGV[2];
# Read the output of curl --version
open(CURL, $ARGV[1]) || die "Cannot open curl --version list in $ARGV[1]\n";
open(CURL, $ARGV[1]) or die "Cannot open curl --version list in $ARGV[1]\n";
$_ = <CURL>;
chomp;
/libcurl\/([\.\d]+((-DEV)|(-rc\d)|(-\d+))?)/;
@ -44,7 +44,7 @@ close CURL;
my $curlconfigversion;
# Read the output of curl-config --version/--vernum
open(CURLCONFIG, '-|', 'sh', $ARGV[0], "--$what") || die "Cannot get curl-config --$what list\n";
open(CURLCONFIG, '-|', 'sh', $ARGV[0], "--$what") or die "Cannot get curl-config --$what list\n";
$_ = <CURLCONFIG>;
chomp;
my $filever = $_;

View file

@ -36,20 +36,20 @@ while(@ARGV) {
my $cmd = shift @ARGV;
my $arg = shift @ARGV;
if($cmd eq "mkdir") {
mkdir $arg || die "$!";
mkdir $arg or die "$!";
}
elsif($cmd eq "rmdir") {
rmdir $arg || die "$!";
rmdir $arg or die "$!";
}
elsif($cmd eq "rm") {
unlink $arg || die "$!";
unlink $arg or die "$!";
}
elsif($cmd eq "move") {
my $arg2 = shift @ARGV;
move($arg,$arg2) || die "$!";
move($arg,$arg2) or die "$!";
}
elsif($cmd eq "gone") {
! -e $arg || die "Path $arg exists";
! -e $arg or die "Path $arg exists";
} else {
print "Unsupported command $cmd\n";
exit 1;

View file

@ -94,7 +94,7 @@ elsif($ARGV[0] eq "postprocess") {
unlink "$dirname/plainfile.txt";
rmdir "$dirname/asubdir";
rmdir $dirname || die "$!";
rmdir $dirname or die "$!";
if($#ARGV >= 3) { # Verify mtime if requested
my $checkfile = $ARGV[2];
@ -120,7 +120,7 @@ elsif($ARGV[0] eq "postprocess") {
# -r-?r-?r-? 12 U U 47 Dec 31 2000 rofile.txt
my @canondir;
open(IN, "<$logfile") || die "$!";
open(IN, "<$logfile") or die "$!";
while(<IN>) {
/^(.)(..).(..).(..).\s*(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\S+\s+\S+\s+\S+)\s+(.*)$/;
if($1 eq "d") {
@ -148,7 +148,7 @@ elsif($ARGV[0] eq "postprocess") {
@canondir = sort {substr($a, 57) cmp substr($b, 57)} @canondir;
my $newfile = $logfile . ".new";
open(OUT, ">$newfile") || die "$!";
open(OUT, ">$newfile") or die "$!";
print OUT join('', @canondir);
close(OUT);

View file

@ -649,11 +649,11 @@ sub singletest_preprocess {
@entiretest = prepro($testnum, @entiretest);
# save the new version
open(my $fulltesth, ">", $otest) || die "Failure writing test file";
open(my $fulltesth, ">", $otest) or die "Failure writing test file";
foreach my $bytes (@entiretest) {
print $fulltesth pack('a*', $bytes) or die "Failed to print '$bytes': $!";
}
close($fulltesth) || die "Failure writing test file";
close($fulltesth) or die "Failure writing test file";
# in case the process changed the file, reload it
loadtest("$LOGDIR/test${testnum}");
@ -1001,14 +1001,14 @@ sub singletest_run {
open(my $cmdlog, ">", "$LOGDIR/$CURLLOG") ||
die "Failure writing log file";
print $cmdlog "$CMDLINE\n";
close($cmdlog) || die "Failure writing log file";
close($cmdlog) or die "Failure writing log file";
my $dumped_core;
my $cmdres;
if($gdbthis) {
my $gdbinit = "$TESTDIR/gdbinit$testnum";
open(my $gdbcmd, ">", "$LOGDIR/gdbcmd") || die "Failure writing gdb file";
open(my $gdbcmd, ">", "$LOGDIR/gdbcmd") or die "Failure writing gdb file";
if($gdbthis == 1) {
# gdb mode
print $gdbcmd "set args $cmdargs\n";
@ -1019,7 +1019,7 @@ sub singletest_run {
# lldb mode
print $gdbcmd "set args $cmdargs\n";
}
close($gdbcmd) || die "Failure writing gdb file";
close($gdbcmd) or die "Failure writing gdb file";
}
# Flush output.
@ -1083,9 +1083,9 @@ sub singletest_clean {
logmsg "core dumped\n";
if(0 && $gdb) {
logmsg "running gdb for post-mortem analysis:\n";
open(my $gdbcmd, ">", "$LOGDIR/gdbcmd2") || die "Failure writing gdb file";
open(my $gdbcmd, ">", "$LOGDIR/gdbcmd2") or die "Failure writing gdb file";
print $gdbcmd "bt\n";
close($gdbcmd) || die "Failure writing gdb file";
close($gdbcmd) or die "Failure writing gdb file";
runclient("$gdb --directory libtest -x $LOGDIR/gdbcmd2 -batch " . shell_quote($DBGCURL) . " core ");
# unlink("$LOGDIR/gdbcmd2");
}
@ -1336,7 +1336,7 @@ sub controlleripccall {
my $margs = freeze \@_;
# Send IPC call via pipe
length($margs) < 1000 || die "A large IPC write risks blocking on some platforms";
length($margs) < 1000 or die "A large IPC write risks blocking on some platforms";
my $err;
while(! defined ($err = syswrite($controllerw{$runnerid}, (pack "L", length($margs)) . $margs)) || $err <= 0) {
if((!defined $err && ! $!{EINTR}) || (defined $err && $err == 0)) {
@ -1407,7 +1407,7 @@ sub runnerar_ready {
$maxfileno = $fd;
}
}
$maxfileno || die "Internal error: no runners are available to wait on\n";
$maxfileno or die "Internal error: no runners are available to wait on\n";
# Wait for any pipe from any runner to be ready
# This may be interrupted and return EINTR, but this is ignored and the

View file

@ -392,7 +392,7 @@ sub showdiff {
my $file1 = "$logdir/check-generated";
my $file2 = "$logdir/check-expected";
open(my $temp, ">", $file1) || die "Failure writing diff file";
open(my $temp, ">", $file1) or die "Failure writing diff file";
for(@$firstref) {
my $l = $_;
$l =~ s/\r/[CR]/g;
@ -401,9 +401,9 @@ sub showdiff {
print $temp $l;
print $temp "\n";
}
close($temp) || die "Failure writing diff file";
close($temp) or die "Failure writing diff file";
open($temp, ">", $file2) || die "Failure writing diff file";
open($temp, ">", $file2) or die "Failure writing diff file";
for(@$secondref) {
my $l = $_;
$l =~ s/\r/[CR]/g;
@ -412,7 +412,7 @@ sub showdiff {
print $temp $l;
print $temp "\n";
}
close($temp) || die "Failure writing diff file";
close($temp) or die "Failure writing diff file";
my @out = qx(diff -u $file2 $file1 2>$dev_null);
if(!$out[0]) {
@ -561,7 +561,7 @@ sub checksystemfeatures {
$CURLVERSION = $1;
$CURLVERNUM = $CURLVERSION;
$CURLVERNUM =~ s/^([0-9.]+)(.*)/$1/; # leading dots and numbers
$curl =~ s/^(.*)(libcurl.*)/$1/g || die "Failure determining curl binary version";
$curl =~ s/^(.*)(libcurl.*)/$1/g or die "Failure determining curl binary version";
$libcurl = $2;
if($curl =~ /win32|Windows|windows|mingw(32|64)/) {
@ -1294,7 +1294,7 @@ sub singletest_check {
my $loadfile = $hash{'loadfile'};
if($loadfile) {
open(my $tmp, "<", $loadfile) || die "Cannot open file $loadfile: $!";
open(my $tmp, "<", $loadfile) or die "Cannot open file $loadfile: $!";
@validstdout = <$tmp>;
close($tmp);
@ -2347,7 +2347,7 @@ sub createrunners {
#
sub pickrunner {
my ($testnum) = @_;
scalar(@runnersidle) || die "No runners available";
scalar(@runnersidle) or die "No runners available";
return pop @runnersidle;
}
@ -2678,7 +2678,7 @@ if(!$randseed) {
open(my $curlvh, "-|", exerunner() . shell_quote($CURL) . " --version 2>$dev_null") ||
die "could not get curl version!";
my @c = <$curlvh>;
close($curlvh) || die "could not get curl version!";
close($curlvh) or die "could not get curl version!";
# use the first line of output and get the md5 out of it
my $str = md5($c[0]);
$randseed += unpack('S', $str); # unsigned 16-bit value
@ -2855,7 +2855,7 @@ sub disabledtests {
if($TESTCASES eq "all") {
# Get all commands and find out their test numbers
opendir(DIR, $TESTDIR) || die "cannot opendir $TESTDIR: $!";
opendir(DIR, $TESTDIR) or die "cannot opendir $TESTDIR: $!";
my @cmds = grep { /^test([0-9]+)$/ && -f "$TESTDIR/$_" } readdir(DIR);
closedir(DIR);

View file

@ -365,7 +365,7 @@ if($tstunnel_windows) {
# Put an "exec" in front of the command so that the child process
# keeps this child's process ID by being tied to the spawned shell.
exec("exec $cmd") || die "Cannot exec() $cmd: $!";
exec("exec $cmd") or die "Cannot exec() $cmd: $!";
# exec() creates a new process, but ties the existence of the
# new process to the parent waiting perl.exe and sh.exe processes.

View file

@ -351,7 +351,7 @@ sub startnew {
# Put an "exec" in front of the command so that the child process
# keeps this child's process ID.
exec("exec $cmd") || die "Cannot exec() $cmd: $!";
exec("exec $cmd") or die "Cannot exec() $cmd: $!";
# exec() should never return back here to this process. We protect
# ourselves by calling die() in case something goes really bad.
@ -362,7 +362,7 @@ sub startnew {
if($fakepidfile) {
if(open(my $out, ">", $pidfile)) {
print $out $child . "\n";
close($out) || die "Failure writing pidfile";
close($out) or die "Failure writing pidfile";
logmsg "startnew: $pidfile faked with pid=$child\n" if($verbose);
}
else {

View file

@ -1185,7 +1185,7 @@ if($sshdid =~ /OpenSSH-Windows/) {
# Put an "exec" in front of the command so that the child process
# keeps this child's process ID by being tied to the spawned shell.
exec("exec $cmd") || die "Cannot exec() $cmd: $!";
exec("exec $cmd") or die "Cannot exec() $cmd: $!";
# exec() creates a new process, but ties the existence of the
# new process to the parent waiting perl.exe and sh.exe processes.

View file

@ -66,7 +66,7 @@ my %rem;
# included by it, which *should* be all headers
sub scanenum {
my ($file) = @_;
open my $h_in, "-|", "$Cpreprocessor $i$file" || die "Cannot preprocess $file";
open my $h_in, "-|", "$Cpreprocessor $i$file" or die "Cannot preprocess $file";
while(<$h_in>) {
if(/enum\s+(\S+\s+)?{/ .. /}/) {
s/^\s+//;
@ -76,7 +76,7 @@ sub scanenum {
push @syms, $_;
}
}
close $h_in || die "Error preprocessing $file";
close $h_in or die "Error preprocessing $file";
}
sub scanheader {

View file

@ -51,7 +51,7 @@ if(!defined $root) {
}
$root = "$root/include/curl";
opendir(D, $root) || die "Cannot open directory $root: $!\n";
opendir(D, $root) or die "Cannot open directory $root: $!\n";
my @dir = readdir(D);
closedir(D);
@ -68,7 +68,7 @@ my $misses = 0;
my @out;
foreach my $f (@incs) {
open H, "<$f" || die;
open H, "<$f" or die;
my $first = "";
while(<H>) {
s/CURL_DEPRECATED\(.*"\)//;

View file

@ -56,7 +56,7 @@ sub scanconf {
}
sub scan_configure {
opendir(my $m, "$root/m4") || die "Cannot opendir $root/m4: $!";
opendir(my $m, "$root/m4") or die "Cannot opendir $root/m4: $!";
my @m4 = grep { /\.m4$/ } readdir($m);
closedir $m;
scanconf("$root/configure.ac");
@ -110,7 +110,7 @@ sub scan_file {
sub scan_dir {
my ($dir) = @_;
opendir(my $dh, $dir) || die "Cannot opendir $dir: $!";
opendir(my $dh, $dir) or die "Cannot opendir $dir: $!";
my @cfiles = grep { /\.[ch]\z/ && -f "$dir/$_" } readdir($dh);
closedir $dh;
for my $f (sort @cfiles) {

View file

@ -113,7 +113,7 @@ sub scanenums {
}
}
}
close H_IN || die "Error preprocessing $file";
close H_IN or die "Error preprocessing $file";
}
sub scanheader {
@ -134,7 +134,7 @@ sub scanheader {
close H;
}
opendir(my $dh, $incdir) || die "Cannot opendir $incdir: $!";
opendir(my $dh, $incdir) or die "Cannot opendir $incdir: $!";
my @hfiles = grep { /\.h$/ } readdir($dh);
closedir $dh;

View file

@ -258,7 +258,7 @@ if(!glob("$libdocdir/*.3")) {
}
# Get header filenames,
opendir(my $dh, $incdir) || die "Cannot opendir $incdir";
opendir(my $dh, $incdir) or die "Cannot opendir $incdir";
my @hfiles = grep { /\.h$/ } readdir($dh);
closedir $dh;

View file

@ -78,7 +78,7 @@ sub scanmanpage {
close(H);
}
opendir(my $dh, $curlh) || die "Cannot opendir $curlh: $!";
opendir(my $dh, $curlh) or die "Cannot opendir $curlh: $!";
my @hfiles = grep { /\.h$/ } readdir($dh);
closedir $dh;

View file

@ -44,7 +44,7 @@ else {
}
# first run the help command
my @curlout; open(O, '-|', $curl, '-h', $opt) || die; push @curlout, <O>; close(O);
my @curlout; open(O, '-|', $curl, '-h', $opt) or die; push @curlout, <O>; close(O);
# figure out the short+long option combo using -h all*/
open(C, '-|', $curl, '-h', 'all');

View file

@ -33,7 +33,7 @@ my %typecheck; # from the include file
my %enum; # from libcurl-errors.3
sub gettypecheck {
open(my $f, "<", "$root/include/curl/typecheck-gcc.h") || die "no typecheck file";
open(my $f, "<", "$root/include/curl/typecheck-gcc.h") or die "no typecheck file";
while(<$f>) {
chomp;
if($_ =~ /\(option\) == (CURL[^ \)]*)/) {
@ -45,7 +45,7 @@ sub gettypecheck {
sub getinclude {
my $f;
open($f, "<", "$root/include/curl/curl.h") || die "no curl.h";
open($f, "<", "$root/include/curl/curl.h") or die "no curl.h";
while(<$f>) {
if($_ =~ /\((CURLOPT[^,]*), (CURLOPTTYPE_[^,]*)/) {
my ($opt, $type) = ($1, $2);
@ -60,7 +60,7 @@ sub getinclude {
$enum{"CURLOPT_CONV_TO_NETWORK_FUNCTION"}++;
close($f);
open($f, "<", "$root/include/curl/multi.h") || die "no curl.h";
open($f, "<", "$root/include/curl/multi.h") or die "no curl.h";
while(<$f>) {
if($_ =~ /\((CURLMOPT[^,]*), (CURLOPTTYPE_[^,]*)/) {
my ($opt, $type) = ($1, $2);

View file

@ -45,7 +45,7 @@ my $error = 0;
sub cmdfiles {
my ($dir) = @_;
opendir(my $dh, $dir) || die "Cannot opendir $dir: $!";
opendir(my $dh, $dir) or die "Cannot opendir $dir: $!";
my @opts = grep { /[a-z0-9].*\.md$/ && -f "$dir/$_" } readdir($dh);
closedir $dh;