bogofilter's exit codes

Malcolm Dew-Jones yf110 at victoria.tc.ca
Mon Jul 28 19:05:07 CEST 2003



-- 

On Mon, 28 Jul 2003, Boris 'pi' Piwinger wrote:

> David Relson <relson at osagesoftware.com> wrote:
>
> >It has been suggested that the exit codes should be:
> >
> >0 - for spam
> >1 - for ham
> >2 - for unsure
> >3 - for error
> >
> >I'm thinking of making the change for the next release, i.e. version 0.14.1?
> >
> >All in favor say "Yeah".
> >All opposed say "Nay".
>
> Yeah.
>
> pi
>

I would suggest that the error code return the calculated
probability as a percent (i.e. 0-100), and errors return a much
higher value, (e.g. 200 and above).  That way scripts can examine the
probability and use it any way they wish.

E.g. if the probability is calculated as .5 then the the error code is set
to 50, (i.e. 50%).

We patch bogofilter to do this, Our patch is just a hack that intercepts
the exit() call and uses spamicity as a global symbol, so I wouldn't want
to use it in your main code base, but the calculations themselves are
trivial, and are shown here.


+    if ( exit_code_is_percent )
+    {
+
+        if ( exitcode > 1 || spamicity == -1 )
+        {   /* if returning an error, or if the spamicity is not calculated
+               yet, then return the exit code but offset by 200
+            */
+            _exit( exitcode + 200 );
+        }
+        else
+        {   /* spamicity found, and no error being returned,
+               so return the rating as a percent ( 0 - 100)
+            */
+            _exit( (int) (spamicity*100) ) ;
+        }
+    }

$0.02




More information about the bogofilter-dev mailing list