summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2005-12-31 15:00:15 +0000
committerrillig <rillig@pkgsrc.org>2005-12-31 15:00:15 +0000
commitea3cb56d3056119c2965508e542513de0f035ada (patch)
tree124b02552c67be6d9e2e08ac5198fd5216d20445 /pkgtools
parente025ed8e6186579745dff49470564d4dab484db7 (diff)
downloadpkgsrc-ea3cb56d3056119c2965508e542513de0f035ada.tar.gz
- Moved the code that checks for valid shell words into its own subroutine
because it will be extended soon.
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkglint/files/pkglint.pl54
1 files changed, 33 insertions, 21 deletions
diff --git a/pkgtools/pkglint/files/pkglint.pl b/pkgtools/pkglint/files/pkglint.pl
index 87d68792b30..689cf97f4e8 100644
--- a/pkgtools/pkglint/files/pkglint.pl
+++ b/pkgtools/pkglint/files/pkglint.pl
@@ -1,5 +1,5 @@
#! @PERL@ -w
-# $NetBSD: pkglint.pl,v 1.439 2005/12/31 14:01:47 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.440 2005/12/31 15:00:15 rillig Exp $
#
# pkglint - static analyzer and checker for pkgsrc packages
@@ -1634,6 +1634,37 @@ sub checkline_mk_text($$) {
}
+sub checkline_mk_shellword($$) {
+ my ($line, $shellword) = @_;
+ my ($rest);
+
+ if ($shellword =~ qr"^\$\{${regex_varname}(?::.+)?\}$") {
+ # TODO: Check whether the variable needs quoting or not.
+ return;
+ }
+
+ if ($shellword =~ qr"^([\w_\-]+)=(([\"']?)\$\{([\w_]+)\}\3)$") {
+ my ($key, $vexpr, undef, $vname) = ($1, $2, $3, $4);
+ my $mod = ($vname =~ regex_gnu_configure_volatile_vars) ? ":M*:Q" : ":Q";
+ my $fixed_vexpr = "\${${vname}${mod}}";
+ $line->log_warning("Please use ${fixed_vexpr} instead of ${vexpr}.");
+ $line->explain("See the pkgsrc guide, section \"quoting guideline\", for details.");
+ $line->replace($shellword, "${key}=${fixed_vexpr}");
+
+ } elsif ($shellword =~ qr"^([\w_\-]+)=(\$\{([\w_]+):Q\})$") {
+ my ($key, $vexpr, $vname) = ($1, $2, $3);
+ my $fixed_vexpr = "\${${vname}:M*:Q}";
+ if ($vname =~ regex_gnu_configure_volatile_vars) {
+ $line->log_warning("Please use ${fixed_vexpr} instead of ${vexpr}.");
+ $line->explain("See the pkgsrc guide, section \"quoting guideline\", for details.");
+ $line->replace($shellword, "${key}=${fixed_vexpr}");
+ }
+
+ } elsif ($shellword ne "" && $shellword !~ qr"^${regex_shellword}$") {
+ $line->log_warning("Invalid shell word \"${shellword}\".");
+ }
+}
+
sub checkline_mk_shelltext($$) {
my ($line, $text) = @_;
my ($vartools, $state, $rest, $set_e_mode);
@@ -2021,26 +2052,7 @@ sub checkline_mk_vartype_basic($$$$$) {
checkline_relative_pkgdir($line, $value);
} elsif ($type eq "ShellWord") {
- if ($value =~ qr"^([\w_\-]+)=(([\"']?)\$\{([\w_]+)\}\3)$") {
- my ($key, $vexpr, undef, $vname) = ($1, $2, $3, $4);
- my $mod = ($vname =~ regex_gnu_configure_volatile_vars) ? ":M*:Q" : ":Q";
- my $fixed_vexpr = "\${${vname}${mod}}";
- $line->log_warning("Please use ${fixed_vexpr} instead of ${vexpr}.");
- $line->explain("See the pkgsrc guide, section \"quoting guideline\", for details.");
- $line->replace($value, "${key}=${fixed_vexpr}");
-
- } elsif ($value =~ qr"^([\w_\-]+)=(\$\{([\w_]+):Q\})$") {
- my ($key, $vexpr, $vname) = ($1, $2, $3);
- my $fixed_vexpr = "\${${vname}:M*:Q}";
- if ($vname =~ regex_gnu_configure_volatile_vars) {
- $line->log_warning("Please use ${fixed_vexpr} instead of ${vexpr}.");
- $line->explain("See the pkgsrc guide, section \"quoting guideline\", for details.");
- $line->replace($value, "${key}=${fixed_vexpr}");
- }
-
- } elsif ($value ne "" && $value !~ qr"^${regex_shellword}$") {
- $line->log_warning("Invalid shell word \"${value}\".");
- }
+ checkline_mk_shellword($line, $value);
} elsif ($type eq "Stage") {
if ($value !~ qr"^(?:pre|do|post)-(?:extract|patch|configure|build|install)$") {