OpenPKG CVS Repository
http://cvs.openpkg.org/
____________________________________________________________________________
Server: cvs.openpkg.org Name: Thomas Lotterer
Root: /e/openpkg/cvs Email: [EMAIL PROTECTED]
Module: openpkg-re Date: 21-Jul-2003 10:47:22
Branch: HEAD Handle: 2003072109472200
Modified files:
openpkg-re rclint.pl speclint.pl
Log:
PR#210: shtool options space before argument linting
Summary:
Revision Changes Path
1.15 +31 -0 openpkg-re/rclint.pl
1.37 +25 -3 openpkg-re/speclint.pl
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: openpkg-re/rclint.pl
============================================================================
$ cvs diff -u -r1.14 -r1.15 rclint.pl
--- openpkg-re/rclint.pl 20 Jul 2003 20:38:08 -0000 1.14
+++ openpkg-re/rclint.pl 21 Jul 2003 08:47:22 -0000 1.15
@@ -458,11 +458,42 @@
sub check_global {
my ($file, $spec) = @_;
+ # utility function: extract a single shell command
+ sub command_extract {
+ my ($script) = @_;
+ my $cmd = '';
+ while ($script ne '') {
+ $script =~ s/^([ \t]*'[^']*')/ $cmd .= $1, ''/se && next;
+ $script =~ s/^([ \t]*"[^"]*")/ $cmd .= $1, ''/se && next;
+ $script =~ s/^([ \t]*[^ \t;\)\\\r\n]+)/$cmd .= $1, ''/se && next;
+ $script =~ s/^([ \t]*\\[ \t]*\r?\n)/ $cmd .= $1, ''/se && next;
+ last;
+ }
+ return ($cmd, $script);
+ }
+
# check for deprecated use of opServiceEnabled function
my $done = ''; my $this = ''; my $todo = $spec;
while ($todo =~ m/\bopServiceEnabled\b/s) {
$done .= $`; $this = $&; $todo = $';
&lint_warning($file, $done, $this, "deprecated usage of opServiceEnabled
macro (expected rcService ... enable yes)");
+ $done .= $this;
+ }
+
+ my $done = ''; my $this = ''; my $todo = $spec;
+ while ($todo =~ m/shtool\s+/s) {
+ $done .= $`; $this = $&; $todo = $';
+ ($this, $todo) = &command_extract($this . $todo);
+
+ # check for shtool options with no space before argument
+ my $subthis = $this;
+ $subthis =~ s/%{[^}]*?}//sg;
+ $subthis =~ s/'[^']*'//sg;
+ $subthis =~ s/"[^"]*"//sg;
+ $subthis =~ s/[;|&].*$//s; # catch command termination by semicolon, pipe,
or, and;
+ if ($subthis =~ m/\s-[a-zA-Z]\S/) {
+ &lint_warning($file, $done, $this, "found use of shtool option with
space omitted before argument");
+ }
$done .= $this;
}
}
@@ .
patch -p0 <<'@@ .'
Index: openpkg-re/speclint.pl
============================================================================
$ cvs diff -u -r1.36 -r1.37 speclint.pl
--- openpkg-re/speclint.pl 19 Jul 2003 09:58:34 -0000 1.36
+++ openpkg-re/speclint.pl 21 Jul 2003 08:47:22 -0000 1.37
@@ -667,10 +667,32 @@
# check filesystem path style
$done = $outer_done; $this = ''; $todo = $outer_this;
- while ($todo =~ m/\%\{l_shtool\}\s+(mkdir|install)\s+/s) {
+ while ($todo =~ m/\%\{l_shtool\}\s+(\w+)\s+/s) {
$done .= $`; $this = $&; $todo = $';
($this, $todo) = &command_extract($this . $todo);
+ # check for shtool options with no space before argument
+ my $subthis = $this;
+ $subthis =~ s/%{[^}]*?}//sg;
+ # remove content of quoted arguments as they might contain unrelated
things to catch
+ $subthis =~ s/'[^']*'/ARG/sg;
+ $subthis =~ s/"[^"]*"/ARG/sg;
+ $subthis =~ s/`[^`]*`/ARG/sg;
+ # remove us completely if line ends with a quote as this indicates we are
a quoted argument to ourselfs
+ $subthis =~ s/[^']*'$//s;
+ $subthis =~ s/[^"]*"$//s;
+ $subthis =~ s/[^`]*`$//s;
+ $subthis =~ s/[^']*' \\\n//s;
+ $subthis =~ s/[^"]*" \\\n//s;
+ $subthis =~ s/[^`]*` \\\n//s;
+ # catch command termination by semicolon, pipe, or, and;
+ $subthis =~ s/[;|&].*$//s;
+ if ($subthis =~ m/\s-[a-zA-Z]\S/) {
+ print "\nDEBUG: <<<< subthis=%s", $subthis;
+ print "\nDEBUG: >>>> subthis=%s", $subthis;
+ &lint_warning($file, $done, $this, "found use of shtool option with
space omitted before argument");
+ }
+
# openpkg-rc is special because does bootstrap things
last if ($file =~ m|openpkg-rc\.spec$|);
@@ -838,9 +860,9 @@
# check for deprecated use of "shtool install -e @l_...@ %{l_...}"
my $done = ''; my $this = ''; my $todo = $spec;
- while ($todo =~ m/%{l_shtool} [EMAIL PROTECTED](prefix|[mrn](usr|grp))/s) {
+ while ($todo =~ m/%{l_shtool} [EMAIL PROTECTED](prefix|[mrn](usr|grp))\@/s) {
$done .= $`; $this = $&; $todo = $';
- &lint_warning($file, $done, $this, "deprecated usage of \"shtool install -e
[EMAIL PROTECTED]@\" (expected use of %{l_value ...})");
+ &lint_warning($file, $done, $this, "deprecated usage of \"shtool install -e
[EMAIL PROTECTED]@\" (expected use of %{l_value ...})");
$done .= $this;
}
@@ .
______________________________________________________________________
The OpenPKG Project www.openpkg.org
CVS Repository Commit List [EMAIL PROTECTED]