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:   08-Jul-2003 22:06:13
  Branch: HEAD                             Handle: 2003070821061200

  Modified files:
    openpkg-re              rclint.pl

  Log:
    add command section script with whitespace after shell redirection
    check

  Summary:
    Revision    Changes     Path
    1.3         +41 -0      openpkg-re/rclint.pl
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-re/rclint.pl
  ============================================================================
  $ cvs diff -u -r1.2 -r1.3 rclint.pl
  --- openpkg-re/rclint.pl      8 Jul 2003 19:44:30 -0000       1.2
  +++ openpkg-re/rclint.pl      8 Jul 2003 20:06:12 -0000       1.3
  @@ -101,6 +101,7 @@
       blank
       comment
       section
  +    script
   ));
   my @checks = ();
   if ($check eq 'all') {
  @@ -325,6 +326,46 @@
       if ($sections !~ m/^$regex$/s) {
           $regex =~ s|,| |sg;
           &lint_error($file, undef, undef, "invalid run command section order 
(expected \"$regex\")"); 
  +    }
  +}
  +
  +##  _________________________________________________________________
  +##
  +##  CHECK "script": shell scripts
  +##  _________________________________________________________________
  +##
  +
  +sub check_script {
  +    my ($file, $spec) = @_;
  +
  +    my $done = ''; my $this = ''; my $todo = $spec;
  +    while ($todo =~ 
m/(\%(?:config|info|common|status|start|stop|restart|reload|quarterly|hourly|daily|weekly|env))([^\n]*)\n(.*?\n)(?=\%(?:config|info|common|status|start|stop|restart|reload|quarterly|hourly|daily|weekly|env)|$)/s)
 {
  +        $done .= $`; $this = $&; $todo = $';
  +        my ($section, $args, $script) = ($1, $2, $3);
  +
  +        #   perform checks for a single script section
  +        &check_script_section($file, $done, $this, $section, $args, $script);
  +
  +        $done .= $this;
  +    }
  +}
  +
  +sub check_script_section {
  +    my ($file, $outer_done, $outer_this, $section, $args, $script) = @_;
  +
  +    #   skip
  +    return if ($section =~ m/^%(config|info|common|env)$/);
  +
  +    #   remove comment contents
  +    $outer_this =~ s|^[ \t]*#[^\n]*||mg;
  +
  +    #   check shell redirections
  +    my $done = $outer_done; my $this = ''; my $todo = $outer_this;
  +    while (   $todo =~ m/[ \t]+(\d+)?[><][ \t]+\S+/s
  +           or $todo =~ m/[ \t]+[><](\&\d+)?[ \t]+\S+/s) {
  +        $done .= $`; $this = $&; $todo = $';
  +        &lint_warning($file, $done, $this, "section $section: whitespace after 
shell redirection (expected none)");
  +        $done .= $this;
       }
   }
   
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to