Bug 4930 - [review] -e exit code option not working
Summary: [review] -e exit code option not working
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: spamassassin (show other bugs)
Version: 3.1.2
Hardware: All All
: P3 normal
Target Milestone: 3.1.4
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard: can be committed
Keywords:
: 4977 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-05-30 20:31 UTC by cemmitt
Modified: 2006-07-10 09:27 UTC (History)
1 user (show)



Attachment Type Modified Status Actions Submitter/CLA Status
suggested patch patch None Theo Van Dinter [HasCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description cemmitt 2006-05-30 20:31:59 UTC
3.1.2 is not setting a non-zero exit code when a message is classified as spam.

e.g.  spamassassin -e < sample-spam.txt

3.1.1 exit code = 5
3.1.2 exit code = 0
Comment 1 Waller Alexander 2006-06-05 17:27:02 UTC
I found the same on SuSE 10.1. The exit code is always 0. 
Comment 2 Theo Van Dinter 2006-06-05 18:59:33 UTC
Hrm.  This is caused by the fix for bug 3754.  Basically we needed to kluge in a return value when files 
can't be read, etc.  Interestingly, the problem seems to be related to a perl "feature".  Specifically, it 
looks like:

eval { $exitvalue ||= !$iter->run(@targets); };

the decision to set $exitvalue (ala "||=") is made first (because $exitvalue is undefined), then it's set to 
the return from run() -- however, the wanted() function (called from run()) sets the global variable, so 
we get:

$exitvalue = undef; # start
$exitvalue = 5; # set in wanted() via run()
$exitvalue = 1; # set in the eval {}

$ perl -e '$t ||= foo(); sub foo { $t = 5; return 1; } print "$t\n"'
1

So, interesting.  Patch coming shortly.
Comment 3 Theo Van Dinter 2006-06-05 18:59:50 UTC
Created attachment 3547 [details]
suggested patch
Comment 4 Justin Mason 2006-06-29 09:28:02 UTC
wow.  +1
Comment 5 Daryl C. W. O'Shea 2006-07-09 21:52:07 UTC
+1
Comment 6 Theo Van Dinter 2006-07-10 00:04:03 UTC
Sending        spamassassin.raw
Transmitting file data .
Committed revision 420375.
Comment 7 Theo Van Dinter 2006-07-10 16:27:01 UTC
*** Bug 4977 has been marked as a duplicate of this bug. ***