tags:

views:

156

answers:

3

I'm using svnnotify. It works (sends email and all that) but it always outputs some error messages, such as

Use of uninitialized value in substr at /usr/lib/perl5/site_perl/5.8.8/SVN/Notify.pm line 1313.
substr outside of string at /usr/lib/perl5/site\_perl/5.8.8/SVN/Notify.pm line 1313.
Use of uninitialized value in index at /usr/lib/perl5/site\_perl/5.8.8/SVN/Notify.pm line 1313.
Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/site\_perl/5.8.8/SVN/Notify.pm line 1314.

I've tried running it with > /dev/null but no luck. I've tried running it > bla and file bla comes up empty, and the output is shown on screen. Since svnnotify does not have a quiet switch, how can I do this?

A: 

The error is printed on stderr, you can redirect it to /dev/null with 2> /dev/null. Alternatively you can make it not use perl -w.

Lukáš Lalinský
The problem with redirection is that you lose all the error output, not just the annoying noise. There might be errors that you still want to see.
brian d foy
+2  A: 

While the accepted answer certainly works, it isn't (in my opinion) the best answer, because one day you're going to have to maintain this code (or worse, someone else will), and getting it to run with no warnings will make your code that much better. Given the warnings, it looks like the problem isn't you, but it's hard (but not impossible) to imagine that a module in version 2.79 would give errors. Maybe your copy of SVN::Notify is old? Maybe your code (or someone's code) is mucking with the module's internals? It's hard to tell with the few warnings I can see, and I have a feeling there's a bit more to this problem than meets the eye.

Chris Lutz
SVN::Notify is the latest version, I haven't modified it in any way. As long as it works (emails get sent out, and even htmldiff works) I really don't care about any errors.
Vnuk
Warnings have nothing to do with the module version. Although this warning just looks like sloppy coding, the particular warnings change between versions of Perl. What might be a warning now might not have been a warning in previous perls.
brian d foy
This is an issue with the latest version of the module. It's not that hard to tell since you can just look at the code and see what it is doing. There weren't proper guard conditions around the substr calls to ensure it would be within the string.
brian d foy
+7  A: 

It looks like this happens when there is no log message for the commit. Some users may need to have a LART session to fix that. Barring that, the right thing to do is fix the SVN::Notify module and submit the patch to the SVN::Notify RT queue, but too late, I've already submitted the ticket.

Here's the patch:

diff --git a/lib/SVN/Notify.pm b/lib/SVN/Notify.pm
index 3f3672b..5387dd2 100644
--- a/lib/SVN/Notify.pm
+++ b/lib/SVN/Notify.pm
@@ -1308,7 +1308,7 @@ sub prepare_subject {
     }

     # Add the first sentence/line from the log message.
-    unless ($self->{no\_first\_line}) {
+    if (!$self->{no\_first\_line} and defined $self->{message}[0] and length $self->{message}[0] )
         # Truncate to first period after a minimum of 10 characters.
         my $i = index substr($self->{message}[0], 10), '. ';
         $self->{subject} .= $i > 0

I think that takes care of the warnings, but I suspect it's only a band-aid because the design around $self->{no_first_line} seems dodgy.

brian d foy
FYI for others who may not have heard of LART: http://catb.org/jargon/html/L/LART.html
Sinan Ünür