This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=891a19dfabcf8f9a7d062d0db614676413e7dc6d

commit 891a19dfabcf8f9a7d062d0db614676413e7dc6d
Author: Guillem Jover <[email protected]>
AuthorDate: Tue Sep 2 04:54:04 2025 +0200

    dselect: Fix open() calls in method scripts
    
    Use a three-form open(). Do not use bareword file handles.
    
    Changelog: internal
    Warned-by: perlcritic
    Fixes: InputOutput::ProhibitTwoArgOpen
    Fixes: InputOutput::ProhibitBarewordFileHandles
---
 dselect/methods/file/install.sh  | 11 +++++++----
 dselect/methods/media/install.sh | 21 +++++++++++++--------
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/dselect/methods/file/install.sh b/dselect/methods/file/install.sh
index ab46a841c..6ad45204a 100755
--- a/dselect/methods/file/install.sh
+++ b/dselect/methods/file/install.sh
@@ -44,8 +44,9 @@ while true; do
 
         my $version;
 
-       open(P, "< $predep") or die "cannot open $predep: $!\n";
-       while (<P>) {
+        open my $predep_fh, "<", $predep
+            or die "cannot open $predep: $!\n";
+        while (<$predep_fh>) {
                s/\s*\n$//;
                $package = $_ if s/^Package: //i;
                 $version = $_ if s{^Version: }{}i;
@@ -62,7 +63,7 @@ while true; do
                        $invoke = "$binaryprefix$filename[$i]";
                } else {
                        $base = $filename[$i]; $base =~ s,.*/,,;
-                       $c = open(X, "-|");
+                       $c = open my $find_fh, "-|";
                        if (not defined $c) {
                                die "failed to fork for find: $!\n";
                        }
@@ -73,7 +74,9 @@ while true; do
                                     "-name", $base);
                                die "failed to exec find: $!\n";
                        }
-                       while (chop($invoke = <X>)) { last if -f $invoke; }
+                        while (chop($invoke = <$find_fh>)) {
+                            last if -f $invoke;
+                        }
                        $print = $invoke;
                        if (substr($print,0,length($binaryprefix)+1) eq
                            "$binaryprefix/") {
diff --git a/dselect/methods/media/install.sh b/dselect/methods/media/install.sh
index 3d51aa96f..d99279790 100755
--- a/dselect/methods/media/install.sh
+++ b/dselect/methods/media/install.sh
@@ -85,8 +85,9 @@ while true; do
 
         my $version;
 
-       open(P, "< $predep") or die "cannot open $predep: $!\n";
-       while (<P>) {
+        open my $predep_fh, "<", $predep
+            or die "cannot open $predep: $!\n";
+        while (<$predep_fh>) {
                s/\s*\n$//;
                $package = $_ if s/^Package: //i;
                 $version = $_ if s{^Version: }{}i;
@@ -116,7 +117,7 @@ INFO
                        $invoke = "$binaryprefix$filename[$i]";
                } else {
                        $base = $filename[$i]; $base =~ s,.*/,,;
-                       $c = open(X, "-|");
+                        $c = open my $find_fh, "-|";
                        if (not defined $c) {
                                die "failed to fork for find: $!\n";
                        }
@@ -126,7 +127,9 @@ INFO
                                     "-name", $base);
                                die "failed to exec find: $!\n";
                        }
-                       while (chop($invoke = <X>)) { last if -f $invoke; }
+                        while (chop($invoke = <$find_fh>)) {
+                              last if -f $invoke;
+                        }
                        $print = $invoke;
                        if (substr($print,0,length($binaryprefix)+1) eq
                            "$binaryprefix/") {
@@ -167,10 +170,11 @@ perl -MDpkg::Version -MDselect::Method::Media -e '
        my $STATUS = "$vardir/status";
         my (%Installed, %Filename, %Medium);
        print "Get currently installed package versions...";
-       open(IN, "$STATUS") or die "cannot open $STATUS: $!\n";
+        open my $status_fh, "<", $STATUS
+            or die "cannot open $STATUS: $!\n";
        $line = 0;
        { local $/ = "";
-       while (<IN>) {
+        while (<$status_fh>) {
                my %status;
                my @pstat;
                $line++ % 20 or print ".";
@@ -189,9 +193,10 @@ perl -MDpkg::Version -MDselect::Method::Media -e '
        print "\nGot ", scalar keys %Installed, " installed/pending packages\n";
        print "Scanning available packages...";
        $line = 0;
-       open(IN, "$AVAIL") or die("Cannot open $AVAIL: $!\n");
+        open my $avail_fh, "<", $AVAIL
+            or die "Cannot open $AVAIL: $!\n";
        { local $/ = "";
-       while (<IN>) {
+        while (<$avail_fh>) {
                my $updated;
                 $line++ % 20 or print ".";
 

-- 
Dpkg.Org's dpkg

Reply via email to