Bug 160817 - Several general changes to swatch; handling of quotes corrected
Several general changes to swatch; handling of quotes corrected
Status: CLOSED NEXTRELEASE
Product: Fedora
Classification: Fedora
Component: swatch (Show other bugs)
4
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jose Pedro Oliveira
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-06-17 11:40 EDT by John Horne
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-01-06 10:09:36 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch for swatch (7.26 KB, patch)
2005-06-17 11:42 EDT, John Horne
no flags Details | Diff

  None (edit)
Description John Horne 2005-06-17 11:40:12 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050524 Fedora/1.0.4-4 Firefox/1.0.4

Description of problem:
We have used swatch for some time. When installed on to FC3 there were a few problems which I corrected but did not submit them. Since we hit the same problems with FC4, installed a couple of days ago, I am now submitting the changes as a patch against the supplied swatch perl program.

There are only a few changes, and some are quite minor - just typos and reformatting some of the pod documentation. Other changes are: the '-tail' option is ambiguous and is re-implemented as '-file-tail'; the use of single and double-quotes seems to be incorrect. Using "$0" (note the quotes) in config files causes errors; this has been fixed.


John.


Version-Release number of selected component (if applicable):
swatch-3.1.1-3.fc4

How reproducible:
Always

Steps to Reproduce:
1.Create a swatch config file containg "$0".
2.Start up swatch using the config file.
3.
  

Actual Results:  Starting swatch produces errors. The problem seems to be due to swatch unable to handle single and double-quotes around the $0, as such perl gets confused:

====================================================================
Scalar found where operator expected at ./.swatch_script.27548 line 141, near ""/usr/local/bin/bb_event --add --service msgs --colour yellow --title 'Message in messages log file:' --message "$S_"
        (Missing operator before $S_?)
String found where operator expected at ./.swatch_script.27548 line 141, near "$S_", 'MESSAGE' => ""
        (Missing operator before ", 'MESSAGE' => "?)
Scalar found where operator expected at ./.swatch_script.27548 line 141, near "", 'MESSAGE' => "$_"
        (Missing operator before $_?)
String found where operator expected at ./.swatch_script.27548 line 146, near "&Swatch::Actions::exec_command('COMMAND' => ""
  (Might be a runaway multi-line "" string starting on line 141)
        (Missing semicolon on previous line?)
Bareword found where operator expected at ./.swatch_script.27548 line 146, near "/bin/bb_event"
        (Missing operator before bb_event?)
Bareword found where operator expected at ./.swatch_script.27548 line 146, near "--add"
        (Missing operator before add?)
Bareword found where operator expected at ./.swatch_script.27548 line 146, near "--service"
        (Missing operator before service?)
String found where operator expected at ./.swatch_script.27548 line 146, near "title 'Message in messages log file:'"
        (Do you need to predeclare title?)
Bareword found where operator expected at ./.swatch_script.27548 line 146, near "--message"
        (Missing operator before message?)
String found where operator expected at ./.swatch_script.27548 line 146, near "message "$S_""
        (Do you need to predeclare message?)
syntax error at ./.swatch_script.27548 line 141, near ""/usr/local/bin/bb_event --add --service msgs --colour yellow --title 'Message in messages log file:' --message "$S_"
Execution of ./.swatch_script.27548 aborted due to compilation errors.
====================================================================

Expected Results:  Swatch should startup with no errors.

Additional info:

An example config file is (line wrapped by me):

  watchfor = /[^\B.]warning[^\B.]/io
        exec = /usr/local/bin/bb_event --add --service msgs --colour yellow 
               --title 'Message in messages log file:' --message "$0"
Comment 1 John Horne 2005-06-17 11:42:53 EDT
Created attachment 115614 [details]
Patch for swatch

I'm not an expert on producing patch files but hopefully this one is okay! I
used 'diff -ruN'.
Comment 2 Jose Pedro Oliveira 2005-06-17 12:32:27 EDT
John,

Diff -ruN is fine for generating patches.

I skimmed through your patch and I wouldn't change the regular expression
that detects empty lines.  The original one is better as it also ignores
lines with only white spaces (the \s* should stay). 

...
@@ -569,8 +576,8 @@
     s/^\s+//; ## strip off leading blank space
     s/\s+$//; ## strip off trailing blank space
 
-    ### Skip comments blank lines ###
-    next if (/^\#/ or /^\s*$/);
+    ### Skip comments and blank lines ###
+    next if (/^\#/ or /^$/);
 
     s/\#.*$//; ## strip trailing comments
... 


By the way, have you tried to send the patch to the author
(http://swatch.sourceforge.net/) ?

Regards,
jpo
Comment 3 John Horne 2005-06-17 12:57:29 EDT
No, the '\s*' is not required because the previous 2 lines remove trailing and
leading blanks:

     s/^\s+//; ## strip off leading blank space
     s/\s+$//; ## strip off trailing blank space

As such you can't possibly have a line with only spaces or tabs in it by the
time you reach the 'next' statement.

Yes I submitted the patch to the author at sourceforge - look at July 2004,
patches '[ 986013 ] Fix exec command and awk option'. It wasn't picked up by the
author, but has a comment by another user who had problems downloading the
patch. I have, however, just downloaded the patch myself (again), and it is
still fine - all there, no funny characters or anything.

Comment 4 John Horne 2005-06-17 13:06:31 EDT
I've just noticed that there are one or two differences between the patch at
sourceforge and the one I submitted here. I would use the patch submitted here
because it was produced later, and it is what we have been using on FC3 and FC4
with no problems.
Comment 5 Jose Pedro Oliveira 2005-08-29 16:01:25 EDT
John,

Sorry for the delay.  Could you build this SRPM
  http://gsd.di.uminho.pt/jpo/software/fedora/swatch-3.1.1-4.src.rpm
  http://gsd.di.uminho.pt/jpo/software/fedora/swatch.spec
and give it a test run?

TIA,
jpo
Comment 6 John Horne 2005-08-30 08:15:54 EDT
Built the RPM from the SRPM/spec file and installed it. Tested by sending some
messages to the swatch monitored log files. All were detected fine - including
the ones using "$0" :-)



John.
Comment 7 Jose Pedro Oliveira 2006-01-06 10:09:36 EST
Built for FC-3, FC-4, and devel.

Note You need to log in before you can comment on or make changes to this bug.