pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/lintpkgsrc lintpkgsrc: fix Perl warning when ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/7f6c84c139f8
branches:  trunk
changeset: 378054:7f6c84c139f8
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Wed Apr 27 22:24:16 2022 +0000

description:
lintpkgsrc: fix Perl warning when parsing variable expressions

When parse-guessing a package Makefile, lintpkgsrc tries to evaluate
variable expressions such as ${VAR:S,from,to,} by passing them through
Perl's eval function.

In a variable expression of the form ${VAR:S,@exec@,${exec},}, this
produced Perl warnings due to the unescaped '@':

        Possible unintended interpolation of @exec in string at
        (eval 63841) line 1.

As a quick fix, skip ':S' modifiers that contain the character '@' for
now.  A proper fix will follow.

diffstat:

 pkgtools/lintpkgsrc/Makefile            |  4 ++--
 pkgtools/lintpkgsrc/files/lintpkgsrc.pl |  8 ++++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diffs (64 lines):

diff -r dfdb971b695c -r 7f6c84c139f8 pkgtools/lintpkgsrc/Makefile
--- a/pkgtools/lintpkgsrc/Makefile      Wed Apr 27 21:15:23 2022 +0000
+++ b/pkgtools/lintpkgsrc/Makefile      Wed Apr 27 22:24:16 2022 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.37 2022/01/01 13:27:37 rillig Exp $
+# $NetBSD: Makefile,v 1.38 2022/04/27 22:25:22 rillig Exp $
 
-PKGNAME=       lintpkgsrc-4.97
+PKGNAME=       lintpkgsrc-4.98
 CATEGORIES=    pkgtools
 
 MAINTAINER=    pkgsrc-users%NetBSD.org@localhost
diff -r dfdb971b695c -r 7f6c84c139f8 pkgtools/lintpkgsrc/files/lintpkgsrc.pl
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl   Wed Apr 27 21:15:23 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl   Wed Apr 27 22:24:16 2022 +0000
@@ -1,6 +1,6 @@
 #!@PERL5@
 
-# $NetBSD: lintpkgsrc.pl,v 1.21 2022/01/01 13:27:37 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.22 2022/04/27 22:24:16 rillig Exp $
 
 # Written by David Brownlee <abs%netbsd.org@localhost>.
 #
@@ -485,6 +485,7 @@
         $cmp = deweycmp_extract( $match_nb, $val_nb );
     }
 
+    debug("eval deweycmp $cmp $test 0\n");
     eval "$cmp $test 0";
 }
 
@@ -1309,7 +1310,7 @@
                 foreach (@patterns) {
                     if (m#(U)(.*)#) {
                        $result ||= $2;
-                    } elsif (m#([CS])(.)([^/]+)\2([^/]*)\2([1g]*)#) {
+                    } elsif (m#([CS])(.)([^/@]+)\2([^/@]*)\2([1g]*)#) {
 
                         my ( $how, $from, $to, $global ) = ( $1, $3, $4, $5 );
 
@@ -1332,6 +1333,7 @@
                         debug(
                             "$file: substituteperl $subvar, $how, $from, $to\n"
                         );
+                        debug("eval substitute <$from> <$to> <$global>\n");
                         eval "\$result =~ s/$from/$to/$global";
                         if ( defined $notfirst ) {
                             $result .= " $notfirst";
@@ -1456,6 +1458,7 @@
     }
 
     if ( $test !~ /[^<>\d()\s&|.!]/ ) {
+       debug("eval test $test\n");
         $false = eval "($test)?0:1";
         if ( !defined $false ) {
             fail("Eval failed $line - $test");
@@ -1686,6 +1689,7 @@
     our ( $pkgcnt, $pkgnum, $subpkgcnt, $subpkgnum );
     $pkglist = new PkgList;
     while (<STORE>) {
+       debug("eval store $_");
         eval $_;
     }
     close(STORE);



Home | Main Index | Thread Index | Old Index