Selaa lähdekoodia

perl: Switch to use low precedence boolean operators for error checks

This will make it safe to remove parenthesis around builtins.
Guillem Jover 12 vuotta sitten
vanhempi
commit
bd281a3259

+ 5 - 5
dselect/methods/Dselect/Ftp.pm

@@ -44,9 +44,9 @@ sub read_config {
   my ($code, $conf);
 
   local($/);
-  open(my $vars_fh, '<', $vars) ||
-    die "couldn't open '$vars': $!\n" .
-        "Try to relaunch the 'Access' step in dselect, thanks.\n";
+  open(my $vars_fh, '<', $vars)
+    or die "couldn't open '$vars': $!\n" .
+           "Try to relaunch the 'Access' step in dselect, thanks.\n";
   $code = <$vars_fh>;
   close $vars_fh;
 
@@ -71,8 +71,8 @@ sub store_config {
   # Check that config is completed
   return if not $CONFIG{done};
 
-  open(my $vars_fh, '>', $vars) ||
-    die "couldn't open $vars in write mode: $!\n";
+  open(my $vars_fh, '>', $vars)
+    or die "couldn't open $vars in write mode: $!\n";
   print $vars_fh Dumper(\%CONFIG);
   close $vars_fh;
 }

+ 1 - 1
dselect/methods/disk/install

@@ -56,7 +56,7 @@ do
 	perl -e '
 		($binaryprefix,$predep) = @ARGV;
 		$binaryprefix =~ s,/*$,/, if length($binaryprefix);
-		open(P,"< $predep") || die "cannot open $predep: $!\n";
+		open(P, "< $predep") or die "cannot open $predep: $!\n";
 		while (<P>) {
 			s/\s*\n$//;
 			$package= $_ if s/^Package: //i;

+ 4 - 4
dselect/methods/ftp/install

@@ -63,8 +63,8 @@ mkpath(["$methdir/$CONFIG{dldir}"], 0, 0755);
 my %md5sums;
 if (-f "$methdir/md5sums") {
   local $/;
-  open(my $md5sums_fh, '<', "$methdir/md5sums") ||
-    die "couldn't read file $methdir/md5sums";
+  open(my $md5sums_fh, '<', "$methdir/md5sums")
+    or die "couldn't read file $methdir/md5sums";
   my $code = <$md5sums_fh>;
   close $md5sums_fh;
   my $VAR1; ## no critic (Variables::ProhibitUnusedVariables)
@@ -626,8 +626,8 @@ foreach (keys %md5sums) {
   next if (-f $_);
   delete $md5sums{$_};
 }
-open(my $md5sums_fh, '>', "$methdir/md5sums") ||
-  die "can't open $methdir/md5sums in write mode: $!\n";
+open(my $md5sums_fh, '>', "$methdir/md5sums")
+  or die "can't open $methdir/md5sums in write mode: $!\n";
 print $md5sums_fh Dumper(\%md5sums);
 close $md5sums_fh;
 

+ 1 - 1
dselect/methods/multicd/install

@@ -110,7 +110,7 @@ do
 
 	perl -e '
 		($binaryprefix,$predep,$thisdisk) = @ARGV;
-		open(P,"< $predep") || die "cannot open $predep: $!\n";
+		open(P, "< $predep") or die "cannot open $predep: $!\n";
 		while (<P>) {
 			s/\s*\n$//;
 			$package= $_ if s/^Package: //i;

+ 6 - 8
dselect/mkcurkeys.pl

@@ -27,7 +27,7 @@ die 'usage: mkcurkeys.pl <filename> <curses.h>' if @ARGV != 2;
 
 my (%over, %base, %name);
 
-open(my $override_fh, '<', $ARGV[0]) || die $!;
+open(my $override_fh, '<', $ARGV[0]) or die $!;
 while (<$override_fh>) {
     chomp;
     /^#/ && next; # skip comments
@@ -50,7 +50,7 @@ for my $i (1 .. 26) {
 
 my ($k, $v);
 
-open(my $header_fh, '<', $ARGV[1]) || die $!;
+open(my $header_fh, '<', $ARGV[1]) or die $!;
 while (<$header_fh>) {
     s/\s+$//;
     m/#define KEY_(\w+)\s+\d+\s+/ || next;
@@ -71,7 +71,7 @@ while (<$header_fh>) {
 }
 close($header_fh);
 
-printf(<<'END') || die $!;
+printf(<<'END') or die $!;
 /*
  * WARNING - THIS FILE IS GENERATED AUTOMATICALLY - DO NOT EDIT
  * It is generated by mkcurkeys.pl from <curses.h>
@@ -111,11 +111,11 @@ for my $i (1 .. 63) {
 
 p($comma, ',');
 
-print(<<'END') || die $!;
+print(<<'END') or die $!;
   { -1,              0                    }
 END
 
-close(STDOUT) || die $!;
+close(STDOUT) or die $!;
 exit(0);
 
 sub capit {
@@ -136,7 +136,5 @@ sub p {
     my ($k, $v) = @_;
 
     $v =~ s/["\\]/\\$&/g;
-    printf("  { %-15s \"%-20s },\n",
-           $k.',',
-           $v.'"') || die $!;
+    printf("  { %-15s \"%-20s },\n", $k . ',', $v . '"') or die $!;
 }

+ 1 - 1
scripts/Dpkg/Changelog/Parse.pm

@@ -141,7 +141,7 @@ sub changelog_parse {
     my $pid = open(my $parser_fh, '-|');
     syserr(_g('cannot fork for %s'), $parser) unless defined $pid;
     if (not $pid) {
-	exec(@exec) || syserr(_g('cannot exec format parser: %s'), $parser);
+	exec(@exec) or syserr(_g('cannot exec format parser: %s'), $parser);
     }
 
     # Get the output into several Dpkg::Control objects

+ 1 - 1
scripts/Dpkg/Checksums.pm

@@ -168,7 +168,7 @@ sub add_from_file {
     }
 
     push @{$self->{files}}, $key unless exists $self->{size}{$key};
-    (my @s = stat($file)) || syserr(_g('cannot fstat file %s'), $file);
+    (my @s = stat($file)) or syserr(_g('cannot fstat file %s'), $file);
     if (exists $self->{size}{$key} and $self->{size}{$key} != $s[7]) {
 	error(_g('file %s has size %u instead of expected %u'),
 	      $file, $s[7], $self->{size}{$key});

+ 4 - 4
scripts/Dpkg/Compression/FileHandle.pm

@@ -384,8 +384,8 @@ sub open_for_write {
 	*$self->{compressor}->compress(from_pipe => \$filehandle,
 		to_file => $self->get_filename());
     } else {
-	CORE::open($filehandle, '>', $self->get_filename) ||
-		syserr(_g('cannot write %s'), $self->get_filename());
+	CORE::open($filehandle, '>', $self->get_filename)
+	    or syserr(_g('cannot write %s'), $self->get_filename());
     }
     *$self->{mode} = 'w';
     *$self->{file} = $filehandle;
@@ -400,8 +400,8 @@ sub open_for_read {
 		from_file => $self->get_filename());
         *$self->{allow_sigpipe} = 1;
     } else {
-	CORE::open($filehandle, '<', $self->get_filename) ||
-		syserr(_g('cannot read %s'), $self->get_filename());
+	CORE::open($filehandle, '<', $self->get_filename)
+	    or syserr(_g('cannot read %s'), $self->get_filename());
     }
     *$self->{mode} = 'r';
     *$self->{file} = $filehandle;

+ 2 - 2
scripts/Dpkg/Control/HashCore.pm

@@ -349,8 +349,8 @@ sub output {
 	    }
 	    # Print it out
             if ($fh) {
-	        print $fh "$key: $value\n" ||
-                    syserr(_g('write error on control data'));
+	        print $fh "$key: $value\n"
+	            or syserr(_g('write error on control data'));
             }
 	    $str .= "$key: $value\n" if defined wantarray;
 	}

+ 4 - 4
scripts/Dpkg/File.pm

@@ -38,13 +38,13 @@ sub file_lock($$) {
     eval 'use File::FcntlLock';
     if ($@) {
         warning(_g('File::FcntlLock not available; using flock which is not NFS-safe'));
-        flock($fh, LOCK_EX) ||
-            syserr(_g('failed to get a write lock on %s'), $filename);
+        flock($fh, LOCK_EX)
+            or syserr(_g('failed to get a write lock on %s'), $filename);
     } else {
         eval q{
             my $fs = File::FcntlLock->new(l_type => F_WRLCK);
-            $fs->lock($fh, F_SETLKW) ||
-                syserr(_g('failed to get a write lock on %s'), $filename);
+            $fs->lock($fh, F_SETLKW)
+                or syserr(_g('failed to get a write lock on %s'), $filename);
         }
     }
 }

+ 19 - 16
scripts/Dpkg/IPC.pm

@@ -206,20 +206,20 @@ sub spawn {
     # Create pipes if needed
     my ($input_pipe, $output_pipe, $error_pipe);
     if ($opts{from_pipe}) {
-	pipe($opts{from_handle}, $input_pipe) ||
-		syserr(_g('pipe for %s'), "@prog");
+	pipe($opts{from_handle}, $input_pipe)
+	    or syserr(_g('pipe for %s'), "@prog");
 	${$opts{from_pipe}} = $input_pipe;
 	push @{$opts{close_in_child}}, $input_pipe;
     }
     if ($opts{to_pipe}) {
-	pipe($output_pipe, $opts{to_handle}) ||
-		syserr(_g('pipe for %s'), "@prog");
+	pipe($output_pipe, $opts{to_handle})
+	    or syserr(_g('pipe for %s'), "@prog");
 	${$opts{to_pipe}} = $output_pipe;
 	push @{$opts{close_in_child}}, $output_pipe;
     }
     if ($opts{error_to_pipe}) {
-	pipe($error_pipe, $opts{error_to_handle}) ||
-		syserr(_g('pipe for %s'), "@prog");
+	pipe($error_pipe, $opts{error_to_handle})
+	    or syserr(_g('pipe for %s'), "@prog");
 	${$opts{error_to_pipe}} = $error_pipe;
 	push @{$opts{close_in_child}}, $error_pipe;
     }
@@ -238,30 +238,33 @@ sub spawn {
 	}
 	# Change the current directory
 	if ($opts{chdir}) {
-	    chdir($opts{chdir}) || syserr(_g('chdir to %s'), $opts{chdir});
+	    chdir($opts{chdir}) or syserr(_g('chdir to %s'), $opts{chdir});
 	}
 	# Redirect STDIN if needed
 	if ($opts{from_file}) {
-	    open(STDIN, '<', $opts{from_file}) ||
-		syserr(_g('cannot open %s'), $opts{from_file});
+	    open(STDIN, '<', $opts{from_file})
+	        or syserr(_g('cannot open %s'), $opts{from_file});
 	} elsif ($opts{from_handle}) {
-	    open(STDIN, '<&', $opts{from_handle}) || syserr(_g('reopen stdin'));
+	    open(STDIN, '<&', $opts{from_handle})
+		or syserr(_g('reopen stdin'));
 	    close($opts{from_handle}); # has been duped, can be closed
 	}
 	# Redirect STDOUT if needed
 	if ($opts{to_file}) {
-	    open(STDOUT, '>', $opts{to_file}) ||
-		syserr(_g('cannot write %s'), $opts{to_file});
+	    open(STDOUT, '>', $opts{to_file})
+	        or syserr(_g('cannot write %s'), $opts{to_file});
 	} elsif ($opts{to_handle}) {
-	    open(STDOUT, '>&', $opts{to_handle}) || syserr(_g('reopen stdout'));
+	    open(STDOUT, '>&', $opts{to_handle})
+		or syserr(_g('reopen stdout'));
 	    close($opts{to_handle}); # has been duped, can be closed
 	}
 	# Redirect STDERR if needed
 	if ($opts{error_to_file}) {
-	    open(STDERR, '>', $opts{error_to_file}) ||
-		syserr(_g('cannot write %s'), $opts{error_to_file});
+	    open(STDERR, '>', $opts{error_to_file})
+	        or syserr(_g('cannot write %s'), $opts{error_to_file});
 	} elsif ($opts{error_to_handle}) {
-	    open(STDERR, '>&', $opts{error_to_handle}) || syserr(_g('reopen stdout'));
+	    open(STDERR, '>&', $opts{error_to_handle})
+	        or syserr(_g('reopen stdout'));
 	    close($opts{error_to_handle}); # has been duped, can be closed
 	}
 	# Close some inherited filehandles

+ 4 - 4
scripts/Dpkg/Interface/Storable.pm

@@ -84,11 +84,11 @@ sub load {
 	$desc = _g('<standard input>');
     } else {
 	$fh = Dpkg::Compression::FileHandle->new();
-	open($fh, '<', $file) || syserr(_g('cannot read %s'), $file);
+	open($fh, '<', $file) or syserr(_g('cannot read %s'), $file);
     }
     my $res = $self->parse($fh, $desc, @options);
     if ($file ne '-') {
-	close($fh) || syserr(_g('cannot close %s'), $file);
+	close($fh) or syserr(_g('cannot close %s'), $file);
     }
     return $res;
 }
@@ -112,11 +112,11 @@ sub save {
 	$fh = \*STDOUT;
     } else {
 	$fh = Dpkg::Compression::FileHandle->new();
-	open($fh, '>', $file) || syserr(_g('cannot write %s'), $file);
+	open($fh, '>', $file) or syserr(_g('cannot write %s'), $file);
     }
     $self->output($fh, @options);
     if ($file ne '-') {
-	close($fh) || syserr(_g('cannot close %s'), $file);
+	close($fh) or syserr(_g('cannot close %s'), $file);
     }
 }
 

+ 2 - 2
scripts/Dpkg/Shlibs/Objdump.pm

@@ -120,7 +120,7 @@ sub has_object {
 
 sub is_elf {
     my ($file) = @_;
-    open(my $file_fh, '<', $file) || syserr(_g('cannot read %s'), $file);
+    open(my $file_fh, '<', $file) or syserr(_g('cannot read %s'), $file);
     my ($header, $result) = ('', 0);
     if (read($file_fh, $header, 4) == 4) {
 	$result = 1 if ($header =~ /^\177ELF$/);
@@ -179,7 +179,7 @@ sub analyze {
 
     local $ENV{LC_ALL} = 'C';
     open(my $objdump, '-|', $OBJDUMP, '-w', '-f', '-p', '-T', '-R', $file)
-	|| syserr(_g('cannot fork for %s'), $OBJDUMP);
+        or syserr(_g('cannot fork for %s'), $OBJDUMP);
     my $ret = $self->parse_objdump_output($objdump);
     close($objdump);
     return $ret;

+ 9 - 9
scripts/Dpkg/Source/Archive.pm

@@ -59,8 +59,8 @@ sub _add_entry {
     my $cwd = *$self->{cwd};
     internerr('call create() first') unless *$self->{tar_input};
     $file = $2 if ($file =~ /^\Q$cwd\E\/(.+)$/); # Relative names
-    print({ *$self->{tar_input} } "$file\0") ||
-	    syserr(_g('write on tar input'));
+    print({ *$self->{tar_input} } "$file\0")
+        or syserr(_g('write on tar input'));
 }
 
 sub add_file {
@@ -111,7 +111,7 @@ sub extract {
         my $template = basename($self->get_filename()) .  '.tmp-extract.XXXXX';
         unless (-e $dest) {
             # Kludge so that realpath works
-            mkdir($dest) || syserr(_g('cannot create directory %s'), $dest);
+            mkdir($dest) or syserr(_g('cannot create directory %s'), $dest);
         }
         $tmp = tempdir($template, DIR => Cwd::realpath("$dest/.."), CLEANUP => 1);
         $spawn_opts{chdir} = $tmp;
@@ -142,18 +142,18 @@ sub extract {
     return if $opts{in_place};
 
     # Rename extracted directory
-    opendir(my $dir_dh, $tmp) || syserr(_g('cannot opendir %s'), $tmp);
+    opendir(my $dir_dh, $tmp) or syserr(_g('cannot opendir %s'), $tmp);
     my @entries = grep { $_ ne '.' && $_ ne '..' } readdir($dir_dh);
     closedir($dir_dh);
     my $done = 0;
     erasedir($dest);
     if (scalar(@entries) == 1 && ! -l "$tmp/$entries[0]" && -d _) {
-	rename("$tmp/$entries[0]", $dest) ||
-		syserr(_g('unable to rename %s to %s'),
-		       "$tmp/$entries[0]", $dest);
+	rename("$tmp/$entries[0]", $dest)
+	    or syserr(_g('unable to rename %s to %s'),
+	              "$tmp/$entries[0]", $dest);
     } else {
-	rename($tmp, $dest) ||
-		syserr(_g('unable to rename %s to %s'), $tmp, $dest);
+	rename($tmp, $dest)
+	    or syserr(_g('unable to rename %s to %s'), $tmp, $dest);
     }
     erasedir($tmp);
 }

+ 7 - 6
scripts/Dpkg/Source/Package.pm

@@ -331,7 +331,7 @@ sub find_original_tarballs {
     my @tar;
     foreach my $dir ('.', $self->{basedir}, $self->{options}{origtardir}) {
         next unless defined($dir) and -d $dir;
-        opendir(my $dir_dh, $dir) || syserr(_g('cannot opendir %s'), $dir);
+        opendir(my $dir_dh, $dir) or syserr(_g('cannot opendir %s'), $dir);
         push @tar, map { "$dir/$_" } grep {
 		($opts{include_main} and
 		 /^\Q$basename\E\.orig\.tar\.$opts{extension}$/) or
@@ -471,8 +471,8 @@ sub extract {
         my $format_file = File::Spec->catfile($srcdir, 'format');
 	unless (-e $format_file) {
 	    mkdir($srcdir) unless -e $srcdir;
-	    open(my $format_fh, '>', $format_file) ||
-	        syserr(_g('cannot write %s'), $format_file);
+	    open(my $format_fh, '>', $format_file)
+	        or syserr(_g('cannot write %s'), $format_file);
 	    print $format_fh $self->{fields}{'Format'} . "\n";
 	    close($format_fh);
 	}
@@ -488,8 +488,8 @@ sub extract {
         warning(_g('%s does not exist'), $rules)
             unless $self->{options}{skip_debianization};
     } elsif (-f _) {
-        chmod($s[2] | 0111, $rules) ||
-            syserr(_g('cannot make %s executable'), $rules);
+        chmod($s[2] | 0111, $rules)
+            or syserr(_g('cannot make %s executable'), $rules);
     } else {
         warning(_g('%s is not a plain file'), $rules);
     }
@@ -584,7 +584,8 @@ sub write_dsc {
     unless (defined $filename) {
         $filename = $self->get_basename(1) . '.dsc';
     }
-    open(my $dsc_fh, '>', $filename) || syserr(_g('cannot write %s'), $filename);
+    open(my $dsc_fh, '>', $filename)
+        or syserr(_g('cannot write %s'), $filename);
     $fields->apply_substvars($opts{substvars});
     $fields->output($dsc_fh);
     close($dsc_fh);

+ 21 - 21
scripts/Dpkg/Source/Package/V1.pm

@@ -120,9 +120,9 @@ sub do_extract {
 
         erasedir($newdirectory);
         if (-e $expectprefix) {
-            rename($expectprefix, "$newdirectory.tmp-keep") ||
-                    syserr(_g("unable to rename `%s' to `%s'"), $expectprefix,
-                           "$newdirectory.tmp-keep");
+            rename($expectprefix, "$newdirectory.tmp-keep")
+                or syserr(_g("unable to rename `%s' to `%s'"), $expectprefix,
+                          "$newdirectory.tmp-keep");
         }
 
         info(_g('unpacking %s'), $tarfile);
@@ -138,15 +138,15 @@ sub do_extract {
             subprocerr("cp $expectprefix to $newdirectory.tmp-keep") if $?;
         }
 
-	rename($expectprefix, $newdirectory) ||
-	    syserr(_g('failed to rename newly-extracted %s to %s'),
-	           $expectprefix, $newdirectory);
+	rename($expectprefix, $newdirectory)
+	    or syserr(_g('failed to rename newly-extracted %s to %s'),
+	              $expectprefix, $newdirectory);
 
 	# rename the copied .orig directory
 	if (-e "$newdirectory.tmp-keep") {
-	    rename("$newdirectory.tmp-keep", $expectprefix) ||
-                    syserr(_g('failed to rename saved %s to %s'),
-	                   "$newdirectory.tmp-keep", $expectprefix);
+	    rename("$newdirectory.tmp-keep", $expectprefix)
+	        or syserr(_g('failed to rename saved %s to %s'),
+	                  "$newdirectory.tmp-keep", $expectprefix);
         }
     }
 
@@ -212,8 +212,8 @@ sub do_build {
 	# is to decide the mode to use
         my $origarg = shift(@argv);
         if (length($origarg)) {
-            stat($origarg) ||
-                syserr(_g('cannot stat orig argument %s'), $origarg);
+            stat($origarg)
+                or syserr(_g('cannot stat orig argument %s'), $origarg);
             if (-d _) {
                 $origdir = File::Spec->catdir($origarg);
 
@@ -314,11 +314,11 @@ sub do_build {
 	$tar->create(options => \@tar_ignore, chdir => $tardirbase);
 	$tar->add_directory($tardirname);
 	$tar->finish();
-        rename($newtar, $tarname) ||
-            syserr(_g("unable to rename `%s' (newly created) to `%s'"),
-                   $newtar, $tarname);
-	chmod(0666 &~ umask(), $tarname) ||
-	    syserr(_g("unable to change permission of `%s'"), $tarname);
+	rename($newtar, $tarname)
+	    or syserr(_g("unable to rename `%s' (newly created) to `%s'"),
+	              $newtar, $tarname);
+	chmod(0666 &~ umask(), $tarname)
+	    or syserr(_g("unable to change permission of `%s'"), $tarname);
     } else {
 	info(_g('building %s using existing %s'),
 	     $sourcepackage, $tarname);
@@ -376,11 +376,11 @@ sub do_build {
 		if $self->{options}{abort_on_upstream_changes};
 	}
 
-	rename($newdiffgz, $diffname) ||
-	    syserr(_g("unable to rename `%s' (newly created) to `%s'"),
-	           $newdiffgz, $diffname);
-	chmod(0666 &~ umask(), $diffname) ||
-	    syserr(_g("unable to change permission of `%s'"), $diffname);
+	rename($newdiffgz, $diffname)
+	    or syserr(_g("unable to rename `%s' (newly created) to `%s'"),
+	              $newdiffgz, $diffname);
+	chmod(0666 &~ umask(), $diffname)
+	    or syserr(_g("unable to change permission of `%s'"), $diffname);
 
 	$self->add_file($diffname);
     }

+ 26 - 26
scripts/Dpkg/Source/Package/V2.pm

@@ -201,7 +201,7 @@ sub get_patches {
     my $pd = "$dir/debian/patches";
     my $auto_patch = $self->get_autopatch_name();
     if (-d $pd) {
-        opendir(my $dir_dh, $pd) || syserr(_g('cannot opendir %s'), $pd);
+        opendir(my $dir_dh, $pd) or syserr(_g('cannot opendir %s'), $pd);
         foreach my $patch (sort readdir($dir_dh)) {
             # patches match same rules as run-parts
             next unless $patch =~ /^[\w-]+$/ and -f "$pd/$patch";
@@ -219,8 +219,8 @@ sub apply_patches {
     my @patches = $self->get_patches($dir, %opts);
     return unless scalar(@patches);
     my $applied = File::Spec->catfile($dir, 'debian', 'patches', '.dpkg-source-applied');
-    open(my $applied_fh, '>', $applied) ||
-        syserr(_g('cannot write %s'), $applied);
+    open(my $applied_fh, '>', $applied)
+        or syserr(_g('cannot write %s'), $applied);
     print $applied_fh "# During $opts{usage}\n";
     my $timestamp = fs_time($applied);
     foreach my $patch ($self->get_patches($dir, %opts)) {
@@ -280,8 +280,8 @@ sub after_build {
     my $applied = File::Spec->catfile($dir, 'debian', 'patches', '.dpkg-source-applied');
     my $reason = '';
     if (-e $applied) {
-        open(my $applied_fh, '<', $applied) ||
-            syserr(_g('cannot read %s'), $applied);
+        open(my $applied_fh, '<', $applied)
+            or syserr(_g('cannot read %s'), $applied);
         $reason = <$applied_fh>;
         close($applied_fh);
     }
@@ -460,13 +460,13 @@ sub do_build {
         my $reldir = File::Spec->abs2rel($File::Find::dir, $dir);
         my $cwd = getcwd();
         # Apply the pattern both from the top dir and from the inspected dir
-        chdir($dir) || syserr(_g("unable to chdir to `%s'"), $dir);
+        chdir($dir) or syserr(_g("unable to chdir to `%s'"), $dir);
         $exclude{$_} = 1 foreach glob($tar_ignore_glob);
-        chdir($cwd) || syserr(_g("unable to chdir to `%s'"), $cwd);
-        chdir($File::Find::dir) ||
-            syserr(_g("unable to chdir to `%s'"), $File::Find::dir);
+        chdir($cwd) or syserr(_g("unable to chdir to `%s'"), $cwd);
+        chdir($File::Find::dir)
+            or syserr(_g("unable to chdir to `%s'"), $File::Find::dir);
         $exclude{$_} = 1 foreach glob($tar_ignore_glob);
-        chdir($cwd) || syserr(_g("unable to chdir to `%s'"), $cwd);
+        chdir($cwd) or syserr(_g("unable to chdir to `%s'"), $cwd);
         my @result;
         foreach my $fn (@_) {
             unless (exists $exclude{$fn} or exists $exclude{"$reldir/$fn"}) {
@@ -525,7 +525,7 @@ sub do_build {
              $autopatch) if -e $autopatch;
         rmdir(File::Spec->catdir($dir, 'debian', 'patches')); # No check on purpose
     }
-    unlink($tmpdiff) || syserr(_g('cannot remove %s'), $tmpdiff);
+    unlink($tmpdiff) or syserr(_g('cannot remove %s'), $tmpdiff);
     pop_exit_handler();
 
     # Create the debian.tar
@@ -550,7 +550,7 @@ sub get_patch_header {
     }
     my $text;
     if (-f $ph) {
-        open(my $ph_fh, '<', $ph) || syserr(_g('cannot read %s'), $ph);
+        open(my $ph_fh, '<', $ph) or syserr(_g('cannot read %s'), $ph);
         $text = file_slurp($ph_fh);
         close($ph_fh);
         return $text;
@@ -589,17 +589,17 @@ sub register_patch {
     my ($self, $dir, $patch_file, $patch_name) = @_;
     my $patch = File::Spec->catfile($dir, 'debian', 'patches', $patch_name);
     if (-s $patch_file) {
-        copy($patch_file, $patch) ||
-            syserr(_g('failed to copy %s to %s'), $patch_file, $patch);
-        chmod(0666 & ~ umask(), $patch) ||
-                syserr(_g("unable to change permission of `%s'"), $patch);
+        copy($patch_file, $patch)
+            or syserr(_g('failed to copy %s to %s'), $patch_file, $patch);
+        chmod(0666 & ~ umask(), $patch)
+            or syserr(_g("unable to change permission of `%s'"), $patch);
         my $applied = File::Spec->catfile($dir, 'debian', 'patches', '.dpkg-source-applied');
-        open(my $applied_fh, '>>', $applied) ||
-            syserr(_g('cannot write %s'), $applied);
+        open(my $applied_fh, '>>', $applied)
+            or syserr(_g('cannot write %s'), $applied);
         print $applied_fh "$patch\n";
-        close($applied_fh) || syserr(_g('cannot close %s'), $applied);
+        close($applied_fh) or syserr(_g('cannot close %s'), $applied);
     } elsif (-e $patch) {
-        unlink($patch) || syserr(_g('cannot remove %s'), $patch);
+        unlink($patch) or syserr(_g('cannot remove %s'), $patch);
     }
     return $patch;
 }
@@ -646,7 +646,7 @@ sub do_commit {
     }
     push_exit_handler(sub { unlink($tmpdiff) });
     unless (-s $tmpdiff) {
-        unlink($tmpdiff) || syserr(_g('cannot remove %s'), $tmpdiff);
+        unlink($tmpdiff) or syserr(_g('cannot remove %s'), $tmpdiff);
         info(_g('there are no local changes to record'));
         return;
     }
@@ -661,7 +661,7 @@ sub do_commit {
     my $patch = $self->register_patch($dir, $tmpdiff, $patch_name);
     system('sensible-editor', $patch);
     subprocerr('sensible-editor') if $?;
-    unlink($tmpdiff) || syserr(_g('cannot remove %s'), $tmpdiff);
+    unlink($tmpdiff) or syserr(_g('cannot remove %s'), $tmpdiff);
     pop_exit_handler();
     info(_g('local changes have been recorded in a new patch: %s'), $patch);
 }
@@ -699,8 +699,8 @@ sub load_allowed_binaries {
     my ($self) = @_;
     my $incbin_file = $self->{include_binaries_path};
     if (-f $incbin_file) {
-        open(my $incbin_fh, '<', $incbin_file) ||
-            syserr(_g('cannot read %s'), $incbin_file);
+        open(my $incbin_fh, '<', $incbin_file)
+            or syserr(_g('cannot read %s'), $incbin_file);
         while (defined($_ = <$incbin_fh>)) {
             chomp; s/^\s*//; s/\s*$//;
             next if /^#/ or /^$/;
@@ -724,8 +724,8 @@ sub update_debian_source_include_binaries {
 
     my $incbin_file = $self->{include_binaries_path};
     mkpath(File::Spec->catdir($self->{dir}, 'debian', 'source'));
-    open(my $incbin_fh, '>>', $incbin_file) ||
-        syserr(_g('cannot write %s'), $incbin_file);
+    open(my $incbin_fh, '>>', $incbin_file)
+        or syserr(_g('cannot write %s'), $incbin_file);
     foreach my $binary (@unknown_binaries) {
         print $incbin_fh "$binary\n";
         info(_g('adding %s to %s'), $binary, 'debian/source/include-binaries');

+ 8 - 11
scripts/Dpkg/Source/Package/V3/Bzr.pm

@@ -110,14 +110,13 @@ sub do_build {
     sanity_check($dir);
 
     my $old_cwd = getcwd();
-    chdir($dir) ||
-            syserr(_g("unable to chdir to `%s'"), $dir);
+    chdir($dir) or syserr(_g("unable to chdir to `%s'"), $dir);
 
     # Check for uncommitted files.
     # To support dpkg-source -i, remove any ignored files from the
     # output of bzr status.
-    open(my $bzr_status_fh, '-|', 'bzr', 'status') ||
-            subprocerr('bzr status');
+    open(my $bzr_status_fh, '-|', 'bzr', 'status')
+        or subprocerr('bzr status');
     my @files;
     while (<$bzr_status_fh>) {
         chomp;
@@ -127,14 +126,13 @@ sub do_build {
             push @files, $_;
         }
     }
-    close($bzr_status_fh) || syserr(_g('bzr status exited nonzero'));
+    close($bzr_status_fh) or syserr(_g('bzr status exited nonzero'));
     if (@files) {
         error(_g('uncommitted, not-ignored changes in working directory: %s'),
               join(' ', @files));
     }
 
-    chdir($old_cwd) ||
-            syserr(_g("unable to chdir to `%s'"), $old_cwd);
+    chdir($old_cwd) or syserr(_g("unable to chdir to `%s'"), $old_cwd);
 
     my $tmp = tempdir("$dirname.bzr.XXXXXX", DIR => $updir);
     push_exit_handler(sub { erasedir($tmp) });
@@ -199,15 +197,14 @@ sub do_extract {
     sanity_check($newdirectory);
 
     my $old_cwd = getcwd();
-    chdir($newdirectory) ||
-            syserr(_g("unable to chdir to `%s'"), $newdirectory);
+    chdir($newdirectory)
+        or syserr(_g("unable to chdir to `%s'"), $newdirectory);
 
     # Reconstitute the working tree.
     system('bzr', 'checkout');
     subprocerr('bzr checkout') if $?;
 
-    chdir($old_cwd) ||
-            syserr(_g("unable to chdir to `%s'"), $old_cwd);
+    chdir($old_cwd) or syserr(_g("unable to chdir to `%s'"), $old_cwd);
 }
 
 1;

+ 7 - 9
scripts/Dpkg/Source/Package/V3/Git.pm

@@ -103,7 +103,7 @@ sub do_build {
     sanity_check($dir);
 
     my $old_cwd = getcwd();
-    chdir($dir) || syserr(_g("unable to chdir to `%s'"), $dir);
+    chdir($dir) or syserr(_g("unable to chdir to `%s'"), $dir);
 
     # Check for uncommitted files.
     # To support dpkg-source -i, get a list of files
@@ -119,7 +119,7 @@ sub do_build {
         push @ignores, '--exclude-from=.git/info/exclude';
     }
     open(my $git_ls_files_fh, '-|', 'git', 'ls-files', '--modified', '--deleted',
-         '-z', '--others', @ignores) || subprocerr('git ls-files');
+         '-z', '--others', @ignores) or subprocerr('git ls-files');
     my @files;
     { local $/ = "\0";
       while (<$git_ls_files_fh>) {
@@ -130,7 +130,7 @@ sub do_build {
           }
       }
     }
-    close($git_ls_files_fh) || syserr(_g('git ls-files exited nonzero'));
+    close($git_ls_files_fh) or syserr(_g('git ls-files exited nonzero'));
     if (@files) {
         error(_g('uncommitted, not-ignored changes in working directory: %s'),
               join(' ', @files));
@@ -141,8 +141,7 @@ sub do_build {
     my $tmp;
     my $shallowfile;
     if ($self->{options}{git_depth}) {
-        chdir($old_cwd) ||
-                syserr(_g("unable to chdir to `%s'"), $old_cwd);
+        chdir($old_cwd) or syserr(_g("unable to chdir to `%s'"), $old_cwd);
         $tmp = tempdir("$dirname.git.XXXXXX", DIR => $updir);
         push_exit_handler(sub { erasedir($tmp) });
         my $clone_dir = "$tmp/repo.git";
@@ -153,8 +152,8 @@ sub do_build {
         system('git', 'clone', '--depth=' . $self->{options}{git_depth},
                '--quiet', '--bare', 'file://' . abs_path($dir), $clone_dir);
         subprocerr('git clone') if $?;
-        chdir($clone_dir) ||
-                syserr(_g("unable to chdir to `%s'"), $clone_dir);
+        chdir($clone_dir)
+            or syserr(_g("unable to chdir to `%s'"), $clone_dir);
         $shallowfile = "$basenamerev.gitshallow";
         system('cp', '-f', 'shallow', "$old_cwd/$shallowfile");
         subprocerr('cp shallow') if $?;
@@ -172,8 +171,7 @@ sub do_build {
     );
     subprocerr('git bundle') if $?;
 
-    chdir($old_cwd) ||
-        syserr(_g("unable to chdir to `%s'"), $old_cwd);
+    chdir($old_cwd) or syserr(_g("unable to chdir to `%s'"), $old_cwd);
 
     if (defined $tmp) {
         erasedir($tmp);

+ 5 - 5
scripts/Dpkg/Source/Package/V3/Native.pm

@@ -102,12 +102,12 @@ sub do_build {
     $tar->create(options => \@tar_ignore, chdir => $dirbase);
     $tar->add_directory($dirname);
     $tar->finish();
-    rename($newtar, $tarname) ||
-        syserr(_g("unable to rename `%s' (newly created) to `%s'"),
-               $newtar, $tarname);
+    rename($newtar, $tarname)
+        or syserr(_g("unable to rename `%s' (newly created) to `%s'"),
+                  $newtar, $tarname);
     pop_exit_handler();
-    chmod(0666 &~ umask(), $tarname) ||
-        syserr(_g("unable to change permission of `%s'"), $tarname);
+    chmod(0666 &~ umask(), $tarname)
+        or syserr(_g("unable to change permission of `%s'"), $tarname);
 
     $self->add_file($tarname);
 }

+ 12 - 12
scripts/Dpkg/Source/Package/V3/Quilt.pm

@@ -117,8 +117,8 @@ sub apply_patches {
         my $dest = $quilt->get_patch_file('series');
         unlink($dest) if -l $dest;
         unless (-f _) { # Don't overwrite real files
-            symlink($basename, $dest) ||
-                syserr(_g("can't create symlink %s"), $dest);
+            symlink($basename, $dest)
+                or syserr(_g("can't create symlink %s"), $dest);
         }
     }
 
@@ -129,8 +129,8 @@ sub apply_patches {
         # We're applying the patches in --before-build, remember to unapply
         # them afterwards in --after-build
         my $pc_unapply = $quilt->get_db_file('.dpkg-source-unapply');
-        open(my $unapply_fh, '>', $pc_unapply) ||
-            syserr(_g('cannot write %s'), $pc_unapply);
+        open(my $unapply_fh, '>', $pc_unapply)
+            or syserr(_g('cannot write %s'), $pc_unapply);
         close($unapply_fh);
     }
 
@@ -223,7 +223,7 @@ sub check_patches_applied {
 sub _add_line {
     my ($file, $line) = @_;
 
-    open(my $file_fh, '>>', $file) || syserr(_g('cannot write %s'), $file);
+    open(my $file_fh, '>>', $file) or syserr(_g('cannot write %s'), $file);
     print $file_fh "$line\n";
     close($file_fh);
 }
@@ -231,10 +231,10 @@ sub _add_line {
 sub _drop_line {
     my ($file, $re) = @_;
 
-    open(my $file_fh, '<', $file) || syserr(_g('cannot read %s'), $file);
+    open(my $file_fh, '<', $file) or syserr(_g('cannot read %s'), $file);
     my @lines = <$file_fh>;
     close($file_fh);
-    open($file_fh, '>', $file) || syserr(_g('cannot write %s'), $file);
+    open($file_fh, '>', $file) or syserr(_g('cannot write %s'), $file);
     print($file_fh $_) foreach grep { not /^\Q$re\E\s*$/ } @lines;
     close($file_fh);
 }
@@ -251,12 +251,12 @@ sub register_patch {
     my $patch = $quilt->get_patch_file($patch_name);
 
     if (-s $tmpdiff) {
-        copy($tmpdiff, $patch) ||
-            syserr(_g('failed to copy %s to %s'), $tmpdiff, $patch);
-        chmod(0666 & ~ umask(), $patch) ||
-            syserr(_g("unable to change permission of `%s'"), $patch);
+        copy($tmpdiff, $patch)
+            or syserr(_g('failed to copy %s to %s'), $tmpdiff, $patch);
+        chmod(0666 & ~ umask(), $patch)
+            or syserr(_g("unable to change permission of `%s'"), $patch);
     } elsif (-e $patch) {
-        unlink($patch) || syserr(_g('cannot remove %s'), $patch);
+        unlink($patch) or syserr(_g('cannot remove %s'), $patch);
     }
 
     if (-e $patch) {

+ 7 - 7
scripts/Dpkg/Source/Patch.pm

@@ -125,7 +125,7 @@ sub add_diff_file {
 	    $self->print(*$self->{header}) or syserr(_g('failed to write'));
 	    *$self->{empty} = 0;
 	}
-        print $self $_ || syserr(_g('failed to write'));
+        print $self $_ or syserr(_g('failed to write'));
     }
     close($diffgen) or syserr('close on diff pipe');
     wait_child($diff_pid, nocheck => 1,
@@ -161,7 +161,7 @@ sub add_diff_directory {
         my $fn = (length > length($new)) ? substr($_, length($new) + 1) : '.';
         return if &$diff_ignore($fn);
         $files_in_new{$fn} = 1;
-        lstat("$new/$fn") || syserr(_g('cannot stat file %s'), "$new/$fn");
+        lstat("$new/$fn") or syserr(_g('cannot stat file %s'), "$new/$fn");
         my $mode = S_IMODE((lstat(_))[2]);
         my $size = (lstat(_))[7];
         if (-l _) {
@@ -221,7 +221,7 @@ sub add_diff_directory {
         my $fn = (length > length($old)) ? substr($_, length($old) + 1) : '.';
         return if &$diff_ignore($fn);
         return if $files_in_new{$fn};
-        lstat("$old/$fn") || syserr(_g('cannot stat file %s'), "$old/$fn");
+        lstat("$old/$fn") or syserr(_g('cannot stat file %s'), "$old/$fn");
         if (-f _) {
             if ($inc_removal) {
                 push @diff_files, [$fn, 0, 0, "$old/$fn", '/dev/null',
@@ -295,7 +295,7 @@ sub add_diff_directory {
 
 sub finish {
     my ($self) = @_;
-    close($self) || syserr(_g('cannot close %s'), $self->get_filename());
+    close($self) or syserr(_g('cannot close %s'), $self->get_filename());
     return not *$self->{errors};
 }
 
@@ -570,12 +570,12 @@ sub apply {
     $now ||= fs_time($files[0]) if $opts{force_timestamp} && scalar @files;
     foreach my $fn (@files) {
 	if ($opts{force_timestamp}) {
-	    utime($now, $now, $fn) || $! == ENOENT ||
-		syserr(_g('cannot change timestamp for %s'), $fn);
+	    utime($now, $now, $fn) or $! == ENOENT
+		or syserr(_g('cannot change timestamp for %s'), $fn);
 	}
 	if ($opts{remove_backup}) {
 	    $fn .= '.dpkg-orig';
-	    unlink($fn) || syserr(_g('remove patch backup file %s'), $fn);
+	    unlink($fn) or syserr(_g('remove patch backup file %s'), $fn);
 	}
     }
     return $analysis;

+ 6 - 6
scripts/Dpkg/Source/Quilt.pm

@@ -197,7 +197,7 @@ sub get_db_version {
     my ($self) = @_;
     my $pc_ver = $self->get_db_file('.version');
     if (-f $pc_ver) {
-        open(my $ver_fh, '<', $pc_ver) || syserr(_g('cannot read %s'), $pc_ver);
+        open(my $ver_fh, '<', $pc_ver) or syserr(_g('cannot read %s'), $pc_ver);
         my $version = <$ver_fh>;
         chomp $version;
         close($ver_fh);
@@ -256,7 +256,7 @@ sub read_patch_list {
     return () if not defined $file or not -f $file;
     $opts{warn_options} //= 0;
     my @patches;
-    open(my $series_fh, '<' , $file) || syserr(_g('cannot read %s'), $file);
+    open(my $series_fh, '<' , $file) or syserr(_g('cannot read %s'), $file);
     while (defined($_ = <$series_fh>)) {
         chomp; s/^\s+//; s/\s+$//; # Strip leading/trailing spaces
         s/(^|\s+)#.*$//; # Strip comment
@@ -292,10 +292,10 @@ sub restore_quilt_backup_files {
                 unlink($target);
                 make_path(dirname($target));
                 unless (link($_, $target)) {
-                    copy($_, $target) ||
-                        syserr(_g('failed to copy %s to %s'), $_, $target);
-                    chmod((stat(_))[2], $target) ||
-                        syserr(_g("unable to change permission of `%s'"), $target);
+                    copy($_, $target)
+                        or syserr(_g('failed to copy %s to %s'), $_, $target);
+                    chmod((stat(_))[2], $target)
+                        or syserr(_g("unable to change permission of `%s'"), $target);
                 }
             } else {
                 # empty files are "backups" for new files that patch created

+ 1 - 1
scripts/Dpkg/Vendor.pm

@@ -86,7 +86,7 @@ sub get_vendor_info(;$) {
     my $file = get_vendor_file($vendor);
     return unless $file;
     my $fields = Dpkg::Control::HashCore->new();
-    $fields->load($file) || error(_g('%s is empty'), $file);
+    $fields->load($file) or error(_g('%s is empty'), $file);
     return $fields;
 }
 

+ 2 - 2
scripts/dpkg-checkbuilddeps.pl

@@ -128,8 +128,8 @@ sub parse_status {
 
 	my $facts = Dpkg::Deps::KnownFacts->new();
 	local $/ = '';
-	open(my $status_fh, '<', $status) ||
-		syserr(_g('cannot open %s'), $status);
+	open(my $status_fh, '<', $status)
+		or syserr(_g('cannot open %s'), $status);
 	while (<$status_fh>) {
 		next unless /^Status: .*ok installed$/m;
 

+ 11 - 11
scripts/dpkg-distaddfile.pl

@@ -79,28 +79,28 @@ my ($file, $section, $priority) = @ARGV;
 # of debian/files when parallel building is in use
 my $lockfh;
 my $lockfile = 'debian/control';
-sysopen($lockfh, $lockfile, O_WRONLY) ||
-    syserr(_g('cannot write %s'), $lockfile);
+sysopen($lockfh, $lockfile, O_WRONLY)
+    or syserr(_g('cannot write %s'), $lockfile);
 file_lock($lockfh, $lockfile);
 
-open(my $fileslistnew_fh, '>', "$fileslistfile.new") ||
-    syserr(_g('open new files list file'));
+open(my $fileslistnew_fh, '>', "$fileslistfile.new")
+    or syserr(_g('open new files list file'));
 if (open(my $fileslist_fh, '<', $fileslistfile)) {
     while (<$fileslist_fh>) {
         s/\n$//;
         next if m/^(\S+) / && $1 eq $file;
-        print($fileslistnew_fh "$_\n") ||
-            syserr(_g('copy old entry to new files list file'));
+        print($fileslistnew_fh "$_\n")
+            or syserr(_g('copy old entry to new files list file'));
     }
     close $fileslist_fh or syserr(_g('cannot close %s'), $fileslistfile);
 } elsif ($! != ENOENT) {
     syserr(_g('read old files list file'));
 }
 print($fileslistnew_fh "$file $section $priority\n")
-    || syserr(_g('write new entry to new files list file'));
-close($fileslistnew_fh) || syserr(_g('close new files list file'));
-rename("$fileslistfile.new", $fileslistfile) ||
-    syserr(_g('install new files list file'));
+    or syserr(_g('write new entry to new files list file'));
+close($fileslistnew_fh) or syserr(_g('close new files list file'));
+rename("$fileslistfile.new", $fileslistfile)
+    or syserr(_g('install new files list file'));
 
 # Release the lock
-close($lockfh) || syserr(_g('cannot close %s'), $lockfile);
+close($lockfh) or syserr(_g('cannot close %s'), $lockfile);

+ 8 - 8
scripts/dpkg-genchanges.pl

@@ -230,8 +230,8 @@ if (defined($prev_changelog) and
 }
 
 if (not is_sourceonly) {
-    open(my $fileslist_fh, '<', $fileslistfile) ||
-        syserr(_g('cannot read files list file'));
+    open(my $fileslist_fh, '<', $fileslistfile)
+        or syserr(_g('cannot read files list file'));
     while(<$fileslist_fh>) {
 	if (m/^(([-+.0-9a-z]+)_([^_]+)_([-\w]+)\.u?deb) (\S+) (\S+)$/) {
 	    warning(_g('duplicate files list entry for package %s (line %d)'),
@@ -346,8 +346,8 @@ foreach (keys %{$changelog}) {
 }
 
 if ($changesdescription) {
-    open(my $changes_fh, '<', $changesdescription) ||
-        syserr(_g('read changesdescription'));
+    open(my $changes_fh, '<', $changesdescription)
+        or syserr(_g('read changesdescription'));
     $fields->{'Changes'} = "\n" . file_slurp($changes_fh);
     close($changes_fh);
 }
@@ -406,7 +406,7 @@ if (!is_binaryonly) {
     $dsc= "$uploadfilesdir/${spackage}_${sversion}.dsc";
 
     my $dsc_fields = Dpkg::Control->new(type => CTRL_PKG_SRC);
-    $dsc_fields->load($dsc) || error(_g('%s is empty', $dsc));
+    $dsc_fields->load($dsc) or error(_g('%s is empty', $dsc));
     $checksums->add_from_file($dsc, key => "$spackage\_$sversion.dsc");
     $checksums->add_from_control($dsc_fields, use_files_for_md5 => 1);
 
@@ -447,14 +447,14 @@ if (!is_binaryonly) {
     $origsrcmsg= _g('binary-only upload - not including any source code');
 }
 
-print(STDERR "$Dpkg::PROGNAME: $origsrcmsg\n") ||
-    syserr(_g('write original source message')) unless $quiet;
+print(STDERR "$Dpkg::PROGNAME: $origsrcmsg\n")
+    or syserr(_g('write original source message')) unless $quiet;
 
 $fields->{'Format'} = $substvars->get('Format');
 
 if (!defined($fields->{'Date'})) {
     chomp(my $date822 = `date -R`);
-    $? && subprocerr('date -R');
+    subprocerr('date -R') if $?;
     $fields->{'Date'}= $date822;
 }
 

+ 21 - 20
scripts/dpkg-gencontrol.pl

@@ -333,10 +333,10 @@ if (!defined($substvars->get('Installed-Size'))) {
         syserr(_g('cannot fork for %s'), 'du');
     }
     if (!$c) {
-        chdir("$packagebuilddir") ||
-            syserr(_g("chdir for du to \`%s'"), $packagebuilddir);
-        exec('du', '-k', '-s', '--apparent-size', '.') or
-            syserr(_g('unable to execute %s'), 'du');
+        chdir("$packagebuilddir")
+            or syserr(_g("chdir for du to \`%s'"), $packagebuilddir);
+        exec('du', '-k', '-s', '--apparent-size', '.')
+            or syserr(_g('unable to execute %s'), 'du');
     }
     my $duo = '';
     while (<$du_fh>) {
@@ -370,12 +370,12 @@ my $lockfh;
 my $lockfile = 'debian/control';
 $lockfile = $controlfile if not -e $lockfile;
 
-sysopen($lockfh, $lockfile, O_WRONLY) ||
-    syserr(_g('cannot write %s'), $lockfile);
+sysopen($lockfh, $lockfile, O_WRONLY)
+    or syserr(_g('cannot write %s'), $lockfile);
 file_lock($lockfh, $lockfile);
 
-open(my $fileslistnew_fh, '>', "$fileslistfile.new") ||
-    syserr(_g('open new files list file'));
+open(my $fileslistnew_fh, '>', "$fileslistfile.new")
+    or syserr(_g('open new files list file'));
 binmode($fileslistnew_fh);
 if (open(my $fileslist_fh, '<', $fileslistfile)) {
     binmode($fileslist_fh);
@@ -386,10 +386,10 @@ if (open(my $fileslist_fh, '<', $fileslistfile)) {
 	        && ($3 eq $pkg_type)
 	        && (debarch_eq($2, $fields->{'Architecture'} || '')
 		    || debarch_eq($2, 'all'));
-        print($fileslistnew_fh "$_\n") ||
-            syserr(_g('copy old entry to new files list file'));
+        print($fileslistnew_fh "$_\n")
+            or syserr(_g('copy old entry to new files list file'));
     }
-    close($fileslist_fh) || syserr(_g('close old files list file'));
+    close($fileslist_fh) or syserr(_g('close old files list file'));
 } elsif ($! != ENOENT) {
     syserr(_g('read old files list file'));
 }
@@ -402,19 +402,20 @@ print($fileslistnew_fh $substvars->substvars(sprintf("%s %s %s\n",
                                              $forcefilename,
                                              $fields->{'Section'} || '-',
                                              $fields->{'Priority'} || '-')))
-    || syserr(_g('write new entry to new files list file'));
-close($fileslistnew_fh) || syserr(_g('close new files list file'));
-rename("$fileslistfile.new", $fileslistfile) || syserr(_g('install new files list file'));
+    or syserr(_g('write new entry to new files list file'));
+close($fileslistnew_fh) or syserr(_g('close new files list file'));
+rename("$fileslistfile.new", $fileslistfile)
+    or syserr(_g('install new files list file'));
 
 # Release the lock
-close($lockfh) || syserr(_g('cannot close %s'), $lockfile);
+close($lockfh) or syserr(_g('cannot close %s'), $lockfile);
 
 my $cf;
 my $fh_output;
 if (!$stdout) {
     $cf = $outputfile // "$packagebuilddir/DEBIAN/control";
-    open($fh_output, '>', "$cf.new") ||
-        syserr(_g("cannot open new output control file \`%s'"), "$cf.new");
+    open($fh_output, '>', "$cf.new")
+        or syserr(_g("cannot open new output control file \`%s'"), "$cf.new");
 } else {
     $fh_output = \*STDOUT;
 }
@@ -423,9 +424,9 @@ $fields->apply_substvars($substvars);
 $fields->output($fh_output);
 
 if (!$stdout) {
-    close($fh_output) || syserr(_g('cannot close %s'), "$cf.new");
-    rename("$cf.new", "$cf") ||
-        syserr(_g("cannot install output control file \`%s'"), $cf);
+    close($fh_output) or syserr(_g('cannot close %s'), "$cf.new");
+    rename("$cf.new", "$cf")
+        or syserr(_g("cannot install output control file \`%s'"), $cf);
 }
 
 $substvars->warn_about_unused();

+ 2 - 2
scripts/dpkg-gensymbols.pl

@@ -192,8 +192,8 @@ if (not scalar @files) {
                not check_files_are_the_same($packagebuilddir, $updir)) {
             next PATH if -l $updir;
         }
-	opendir(my $libdir_dh, "$libdir") ||
-	    syserr(_g("can't read directory %s: %s"), $libdir, $!);
+	opendir(my $libdir_dh, "$libdir")
+	    or syserr(_g("can't read directory %s: %s"), $libdir, $!);
 	push @files, grep {
 	    /(\.so\.|\.so$)/ && -f $_ &&
 	    Dpkg::Shlibs::Objdump::is_elf($_);

+ 3 - 2
scripts/dpkg-mergechangelogs.pl

@@ -133,9 +133,10 @@ while (1) {
 }
 
 if (defined($out_file) and $out_file ne '-') {
-    open(my $out_fh, '>', $out_file) || syserr(_g('cannot write %s'), $out_file);
+    open(my $out_fh, '>', $out_file)
+        or syserr(_g('cannot write %s'), $out_file);
     print $out_fh ((blessed $_) ? "$_" : "$_\n") foreach @result;
-    close($out_fh) || syserr(_g('cannot write %s'), $out_file);
+    close($out_fh) or syserr(_g('cannot write %s'), $out_file);
 } else {
     print ((blessed $_) ? "$_" : "$_\n") foreach @result;
 }

+ 2 - 2
scripts/dpkg-name.pl

@@ -92,8 +92,8 @@ sub getfields($)
     my ($filename) = @_;
 
     # Read the fields
-    open(my $cdata_fh, '-|', 'dpkg-deb', '-f', '--', $filename) ||
-        syserr(_g('cannot open %s'), $filename);
+    open(my $cdata_fh, '-|', 'dpkg-deb', '-f', '--', $filename)
+        or syserr(_g('cannot open %s'), $filename);
     my $fields = Dpkg::Control->new(type => CTRL_PKG_DEB);
     $fields->parse($cdata_fh, sprintf(_g('binary control file %s'), $filename));
     close($cdata_fh);

+ 16 - 16
scripts/dpkg-shlibdeps.pl

@@ -457,16 +457,16 @@ my $fh;
 if ($stdout) {
     $fh = \*STDOUT;
 } else {
-    open(my $new_fh, '>', "$varlistfile.new") ||
-	syserr(_g("open new substvars file \`%s'"), "$varlistfile.new");
+    open(my $new_fh, '>', "$varlistfile.new")
+        or syserr(_g("open new substvars file \`%s'"), "$varlistfile.new");
     if (-e $varlistfile) {
-	open(my $old_fh, '<', $varlistfile) ||
-	    syserr(_g("open old varlist file \`%s' for reading"), $varlistfile);
+	open(my $old_fh, '<', $varlistfile)
+	    or syserr(_g("open old varlist file \`%s' for reading"), $varlistfile);
 	while (my $entry = <$old_fh>) {
 	    next if $entry =~ m/^\Q$varnameprefix\E:/;
-	    print($new_fh $entry) ||
-	        syserr(_g("copy old entry to new varlist file \`%s'"),
-	               "$varlistfile.new");
+	    print($new_fh $entry)
+	        or syserr(_g("copy old entry to new varlist file \`%s'"),
+	                  "$varlistfile.new");
 	}
 	close($old_fh);
     }
@@ -537,9 +537,9 @@ foreach my $field (reverse @depfields) {
 
 # Replace old file by new one
 if (!$stdout) {
-    close($fh) || syserr(_g('cannot close %s'), "$varlistfile.new");
-    rename("$varlistfile.new",$varlistfile) ||
-	syserr(_g("install new varlist file \`%s'"), $varlistfile);
+    close($fh) or syserr(_g('cannot close %s'), "$varlistfile.new");
+    rename("$varlistfile.new",$varlistfile)
+        or syserr(_g("install new varlist file \`%s'"), $varlistfile);
 }
 
 ##
@@ -690,8 +690,8 @@ sub extract_from_shlibs {
 	return;
     }
     # Open shlibs file
-    open(my $shlibs_fh, '<', $shlibfile) ||
-        syserr(_g("unable to open shared libs info file \`%s'"), $shlibfile);
+    open(my $shlibs_fh, '<', $shlibfile)
+        or syserr(_g("unable to open shared libs info file \`%s'"), $shlibfile);
     my $dep;
     while (<$shlibs_fh>) {
 	s/\s*\n$//;
@@ -755,8 +755,8 @@ sub symfile_has_soname {
         return $symfile_has_soname_cache{$file}{$soname};
     }
 
-    open(my $symfile_fh, '<', $file) ||
-        syserr(_g('cannot open file %s'), $file);
+    open(my $symfile_fh, '<', $file)
+        or syserr(_g('cannot open file %s'), $file);
     my $result = 0;
     while (<$symfile_fh>) {
 	if (/^\Q$soname\E /) {
@@ -851,14 +851,14 @@ sub find_packages {
 	    or syserr(_g('cannot open file %s'), '/dev/null');
 	$ENV{LC_ALL} = 'C';
 	exec('dpkg', '--search', '--', @files)
-	    || syserr(_g('unable to execute %s'), 'dpkg');
+	    or syserr(_g('unable to execute %s'), 'dpkg');
     }
     while (defined($_ = <$dpkg_fh>)) {
 	chomp($_);
 	if (m/^local diversion |^diversion by/) {
 	    warning(_g('diversions involved - output may be incorrect'));
 	    print(STDERR " $_\n")
-		|| syserr(_g('write diversion info to stderr'));
+		or syserr(_g('write diversion info to stderr'));
 	} elsif (m/^([-a-z0-9+.:, ]+): (\/.*)$/) {
 	    $cached_pkgmatch{$2} = $pkgmatch->{$2} = [ split(/, /, $1) ];
 	} else {

+ 4 - 4
scripts/dpkg-source.pl

@@ -109,14 +109,14 @@ if (defined($options{opmode}) &&
     } else {
 	$dir = File::Spec->catdir(shift(@ARGV));
     }
-    stat($dir) || syserr(_g('cannot stat directory %s'), $dir);
+    stat($dir) or syserr(_g('cannot stat directory %s'), $dir);
     if (not -d $dir) {
 	error(_g('directory argument %s is not a directory'), $dir);
     }
     if ($dir eq '.') {
 	# . is never correct, adjust automatically
 	$dir = basename(cwd());
-	chdir('..') || syserr(_g("unable to chdir to `%s'"), '..');
+	chdir('..') or syserr(_g("unable to chdir to `%s'"), '..');
     }
     # --format options are not allowed, they would take precedence
     # over real command line options, debian/source/format should be used
@@ -354,8 +354,8 @@ if ($options{opmode} =~ /^(-b|--print-format|--(before|after)-build|--commit)$/)
     # Select the format to use
     if (not defined $build_format) {
 	if (-e "$dir/debian/source/format") {
-	    open(my $format_fh, '<', "$dir/debian/source/format") ||
-		syserr(_g('cannot read %s'), "$dir/debian/source/format");
+	    open(my $format_fh, '<', "$dir/debian/source/format")
+	        or syserr(_g('cannot read %s'), "$dir/debian/source/format");
 	    $build_format = <$format_fh>;
 	    chomp($build_format) if defined $build_format;
 	    error(_g('%s is empty'), "$dir/debian/source/format")

+ 1 - 1
scripts/t/600_Dpkg_Changelog.t

@@ -40,7 +40,7 @@ foreach my $file ("$datadir/countme", "$datadir/shadow", "$datadir/fields",
     my $changes = Dpkg::Changelog::Debian->new(verbose => 0);
     $changes->load($file);
 
-    open(my $clog_fh, '<', "$file") || die "can't open $file\n";
+    open(my $clog_fh, '<', "$file") or die "can't open $file\n";
     my $content = file_slurp($clog_fh);
     close($clog_fh);
     cmp_ok($content, 'eq', "$changes", "string output of Dpkg::Changelog on $file");