summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2006-06-06 06:48:16 +0000
committerrillig <rillig@pkgsrc.org>2006-06-06 06:48:16 +0000
commitcf96b37f1858a6739ce90eb3e1600dcb3fa77807 (patch)
tree805676e69df3857f9dc433e5c60354e95735232d /pkgtools
parentfd7633a630bd8a2a5cfed18c7139ecc5195ae51f (diff)
downloadpkgsrc-cf96b37f1858a6739ce90eb3e1600dcb3fa77807.tar.gz
Improved variable_needs_quoting.
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkglint/files/makevars.map4
-rw-r--r--pkgtools/pkglint/files/pkglint.pl34
2 files changed, 30 insertions, 8 deletions
diff --git a/pkgtools/pkglint/files/makevars.map b/pkgtools/pkglint/files/makevars.map
index e6249bf5fc9..5a634d61e2c 100644
--- a/pkgtools/pkglint/files/makevars.map
+++ b/pkgtools/pkglint/files/makevars.map
@@ -1,4 +1,4 @@
-# $NetBSD: makevars.map,v 1.104 2006/06/05 22:24:12 rillig Exp $
+# $NetBSD: makevars.map,v 1.105 2006/06/06 06:48:16 rillig Exp $
#
# This file contains the guessed type of some variables, according to
@@ -416,7 +416,7 @@ PERL5_PACKLIST List of Perl5Packlist [m:s,o:sa]
PERL5_PACKLIST_DIR Pathname []
PGSQL_VERSIONS_ACCEPTED List of { 73 74 80 }
PGSQL_VERSION_DEFAULT Unchecked []
-PKGBASE Unchecked []
+PKGBASE Identifier []
PKGCONFIG_OVERRIDE List of Pathmask [m:as,c:a]
PKGDIR RelativePkgDir
PKGNAME PkgName [m:s,c:s,Makefile.*:ds,*:ds]
diff --git a/pkgtools/pkglint/files/pkglint.pl b/pkgtools/pkglint/files/pkglint.pl
index e2dbd6d7465..95c9f2fc5a8 100644
--- a/pkgtools/pkglint/files/pkglint.pl
+++ b/pkgtools/pkglint/files/pkglint.pl
@@ -1,5 +1,5 @@
#! @PERL@
-# $NetBSD: pkglint.pl,v 1.603 2006/06/06 05:18:56 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.604 2006/06/06 06:48:16 rillig Exp $
#
# pkglint - static analyzer and checker for pkgsrc packages
@@ -2637,6 +2637,7 @@ sub variable_needs_quoting($$$) {
PkgName
RelativePkgDir RelativePkgPath
URL UserGroupName
+ Version
WrkdirSubdirectory
));
@@ -2644,17 +2645,38 @@ sub variable_needs_quoting($$$) {
return dont_know;
}
+ if ($type->kind_of_list == LK_NONE && exists(safe_types->{$type->basic_type})) {
+ return doesnt_matter;
+ }
+
# Determine whether the context expects a list of shell words or
# not.
$want_list = $context->type->is_practically_a_list() && ($context->shellword == VUC_SHELLWORD_BACKT || $context->extent != VUC_EXTENT_WORD_PART);
$have_list = $type->is_practically_a_list();
- if ($type->kind_of_list == LK_NONE && exists(safe_types->{$type->basic_type})) {
- return doesnt_matter;
+ $opt_debug_quoting and $line->log_debug("[variable_needs_quoting]"
+ . " varname=$varname"
+ . " context=" . $context->to_string()
+ . " type=" . $type->to_string()
+ . " want_list=" . ($want_list ? "yes" : "no")
+ . " have_list=" . ($have_list ? "yes" : "no")
+ . ".");
+
+ # Variables that appear as parts of shell words generally need
+ # to be quoted. An exception is in the case of backticks,
+ # because the whole backticks expression is parsed as a single
+ # shell word.
+ #
+ # XXX: When the shell word parser gets rewritten the next time,
+ # this test can be refined.
+ if ($context->extent == VUC_EXTENT_WORD_PART && $context->shellword != VUC_SHELLWORD_BACKT) {
+ return true;
}
- $opt_debug_quoting and $line->log_debug("[variable_needs_quoting] varname $varname context " . $context->to_string() . " type " . $type->to_string());
- $opt_debug_quoting and $line->log_debug(sprintf("[%s] want_list=%d have_list=%d", "variable_needs_quoting", $want_list, $have_list));
+ # Assigning lists to lists does not require any quoting.
+ if ($want_list && $have_list) {
+ return false;
+ }
# Appending elements to a list requires quoting, as well as
# assigning a list value to a non-list variable.
@@ -3108,7 +3130,7 @@ sub checkline_mk_shellword($$$) {
if ($shellword =~ qr"^\$\{(${regex_varname})(:[^{}]+)?\}$") {
my ($varname, $mod) = ($1, $2);
- $opt_warn_quoting and checkline_mk_varuse($line, $varname, defined($mod) ? $mod : "", shellword_vuc);
+ checkline_mk_varuse($line, $varname, defined($mod) ? $mod : "", shellword_vuc);
return;
}