$BOGOFILTER_DIR has no effect, rc example: bogofilter_dir not recognized

Matthias Andree matthias.andree at gmx.de
Mon Apr 21 23:08:33 CEST 2025


Am 21.04.25 um 13:41 schrieb Christian Ebert:
> Hello,
>
> Thanks for taking time to look into this.
>
> * Masaru Nomiya on Monday, April 21, 2025 at 20:08:15 +0900:
>> > [CE] == Christian Ebert <bcc at phloxic.productions> has written:
>>
>> CE>  * Christian Ebert on Saturday, April 19, 2025 at 09:25:30 +0100:
>> CE>  > * Christian Ebert on Friday, April 18, 2025 at 19:44:01 +0100:
>> [...]
>> CE>  man 1 bogofilter:
>>
>> CE>  #v+
>> CE>  ENVIRONMENT
>> CE>         Bogofilter uses a database directory, which can be set in 
>> the config
>> CE>         file. If not set there, bogofilter will use the value of
>> CE>         BOGOFILTER_DIR. Both can be overridden by the -d dir 
>> option. If none of
>> CE>         that is available, bogofilter will use directory 
>> $HOME/.bogofilter.
>> CE>  #v-
>>
>> CE>  Hm, the behaviour I get is very much like:
>>
>> CE>  If not set in a config file, bogofilter-dir will be set "as 
>> defined in the
>> CE>  bogofilter source code" _regardless_ of what the BOGOFILTER_DIR 
>> environment
>> CE>  says.
>>
>> CE>  i.e., BOGOFILTER_DIR never overrides bogofilter-dir - unless when
>> CE>  manually set before invocation.
>>
>> In short, to avoid this on MacOS, it is advisable to source .bashrc
>> within .bash_profile to ensure consistent behavior across shell
>> sessions.
>>
>> Please look into Bash configuration files on MacOS.
>
> $ cat ~/.bash_profile
> if [ ! -r /etc/bashrc ]; then
>     cat <<EOT
> ################################
> # System-wide bashrc not found #
> # or not readable!             #
> ################################
> EOT
> fi
>
> if [ -r /Users/chris/.bashrc ]; then
>     # shellcheck disable=SC1091
>     . /Users/chris/.bashrc
> fi
>
> I really don't understand what's going on.
>
> Did you try $BOGOFILTER_DIR with real mail traffic or just bogofilter 
> -QQ?
>
Christian,

thanks for the report.

Regarding environment variables, you are not trying to set a variable 
whose name begins with a $ sign, are you?

You wrote  >>  export $BOGOFILTER_DIR=... <<  the day before yesterday, 
and that won't work.
The variable is called BOGOFILTER_DIR without $, and in bash you don't 
add the $ when defining or assigning to a variable. You use the $ only 
for expansion of the variable (meaning replacing the variable name by 
its contents) in shells such as POSIX sh, bash, ash, dash, ksh, pdksh 
and maybe other programming languages that expose environment variables 
via $. You haven't shown your /Users/chris/.bashrc nor your /etc/bashrc. 
This is unlike Perl where you always prefix a "scalar" variable 
(including string variable) with a $.

Beyond that, I need to review the source code to see how the parsing 
from command line, environment variables, rcfile goes, and where we use 
- and where we use _. The bf_compact you mentioned appears to be a bug.

https://gitlab.com/bogofilter/bogofilter/-/issues/15 - I intend to fix 
this before the next release candidate (thus before release of 1.3.0).

Regards,
Matthias



More information about the bogofilter mailing list