Bug 6069 - spamc: learning exit codes documentation wrong, possible uncaught error
Summary: spamc: learning exit codes documentation wrong, possible uncaught error
Status: NEW
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: spamc/spamd (show other bugs)
Version: 3.2.5
Hardware: Other All
: P5 normal
Target Milestone: Undefined
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-18 14:22 UTC by Karsten Bräckelmann
Modified: 2009-02-18 18:00 UTC (History)
0 users



Attachment Type Modified Status Actions Submitter/CLA Status

Note You need to log in before you can comment on or make changes to this bug.
Description Karsten Bräckelmann 2009-02-18 14:22:43 UTC
The spamc docs state:

  -L learn type, --learntype=type
      Send message to spamd for learning.  The "learn type" can be either
      spam, ham or forget.  The exitcode for spamc will be set to 5 if
      the message was learned, or 6 if it was already learned.

Doesn't work that way though. The exit code in both cases is 0 success, regardless whether the message has been learned, or not. No difference with the -x option.

  $ spamc -L ham < ham.msg; echo $?
  Message was already un/learned
  0

The code in spamc.c clearly shows, that EX_OK will be returned always. (Just search for "Message was".)  Also applies to trunk, the code didn't change.
Comment 1 Karsten Bräckelmann 2009-02-18 14:32:41 UTC
The fix should be quite trivial, adding 2 lines to set the ret value accordingly. Now I just wonder which one is actually wrong -- the code or the POD...
Comment 2 Karsten Bräckelmann 2009-02-18 15:46:18 UTC
Got the little bugger! :)

rev 158134, looks like this was changed intentional, almost 4 years ago. Alas, the documentation hasn't been adjusted.

Hmm, so successful learning, unavailable (aka previously learned) and even *service unavailable* all are expected to return 0, success?  Seriously?
Comment 3 Karsten Bräckelmann 2009-02-18 15:48:46 UTC
(In reply to comment #2)
> rev 158134

http://svn.apache.org/viewvc?view=rev&revision=158134

Hrm, I was hoping for a link. Sorry for the noise.
Comment 4 Karsten Bräckelmann 2009-02-18 18:00:55 UTC
(In reply to comment #2)
> rev 158134, looks like this was changed intentional, almost 4 years ago. Alas,
> the documentation hasn't been adjusted.
> 
> Hmm, so successful learning, unavailable (aka previously learned) and even
> *service unavailable* all are expected to return 0, success?  Seriously?

More digging.  Turns out all of this is bug 1201, revision 158029 and some fixes after that.

According to bug 1201 comment 47, 48 and 49 returning EX_OK indeed is the desired behavior. Thus, concerning "successful learned" and "already learned" this is a documentation bug.

Still unsure about the removed EX_UNAVAILABLE from revision 158134.

Correcting Summary. And hoping the rev hints get linkified this time.