pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files - Allow '^' to appear unquoted ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/79bb8adceb30
branches:  trunk
changeset: 506133:79bb8adceb30
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu Jan 12 13:51:54 2006 +0000

description:
- Allow '^' to appear unquoted in shell programs, although it ``is an
  obsolete synonym for the pipe operator "|", so you must protect it with
  quotes''. (Kernighan/Pike, The UNIX Programming Environment, 1984.)
- $@ is another well-known shell variable.
- All substitution arguments to ${SED} and ${PAX} should be quoted whether
  they contain special characters or not.

diffstat:

 pkgtools/pkglint/files/pkglint.pl |  16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diffs (45 lines):

diff -r 5b26ef0aab64 -r 79bb8adceb30 pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Thu Jan 12 13:32:47 2006 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Thu Jan 12 13:51:54 2006 +0000
@@ -1,5 +1,5 @@
 #! @PERL@
-# $NetBSD: pkglint.pl,v 1.468 2006/01/12 13:19:57 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.469 2006/01/12 13:51:54 rillig Exp $
 #
 
 # pkglint - static analyzer and checker for pkgsrc packages
@@ -2008,7 +2008,7 @@
                        }
 
                } elsif ($state == SWST_PLAIN) {
-                       if ($rest =~ s/^[!\%&\(\)*+,\-.\/0-9:;<=>?\@A-Z\[\]_a-z{|}~]+//) {
+                       if ($rest =~ s/^[!\%&\(\)*+,\-.\/0-9:;<=>?\@A-Z\[\]^_a-z{|}~]+//) {
                        } elsif ($rest =~ s/^\'//) {
                                $state = SWST_SQUOT;
                        } elsif ($rest =~ s/^\"//) {
@@ -2047,7 +2047,7 @@
                        } elsif ($rest =~ s/^[^\$"\\\`]//) {
                        } elsif ($rest =~ s/^\\(?:[\\\"\`]|\$\$)//) {
                        } elsif ($rest =~ s/^\$\$\{([0-9A-Za-z_]+)\}//
-                           || $rest =~ s/^\$\$([0-9A-Z_a-z]+|[!#?])//) {
+                           || $rest =~ s/^\$\$([0-9A-Z_a-z]+|[!#?\@])//) {
                                my ($varname) = ($1);
                                $line->log_debug("[checkline_mk_shellword] Found double-quoted variable ${varname}.");
                        } elsif ($rest =~ s/^\$\$//) {
@@ -2165,6 +2165,16 @@
                                "INSTALL_MAN_DIR, INSTALL_DATA_DIR.");
                }
 
+               if ($state == SCST_PAX_S || $state == SCST_SED_E) {
+                       if ($shellword !~ qr"^[\"\'].*[\"\']$") {
+                               $line->log_warning("Substitution commands like \"${shellword}\" should always be quoted.");
+                               $line->explain(
+                                       "Usually these substitution commands contain characters like '*' or",
+                                       "other shell metacharacters that might lead to lookup of matching",
+                                       "filenames and then expand to more than one word.");
+                       }
+               }
+
                if ($opt_warn_extra && $shellword eq "|") {
                        $line->log_warning("The exitcode of the left-hand-side command of the pipe operator is ignored.");
                        $line->explain(



Home | Main Index | Thread Index | Old Index