MAILPATH stopped working after update to Bash 4.0

View: New views
7 Messages — Rating Filter:   Alert me  

MAILPATH stopped working after update to Bash 4.0

by Nikos Chantziaras :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have:

   MAILPATH="/home/me/.maildir/new?You have new mail."
   MAILCHECK=60

Bash 3.2 was correctly telling me about new mail arriving.  However,
after I updated to Bash 4.0, I constantly get a "You have new mail."
message every minute even though I actually don't have new mail.  Has
the mail notification feature changed in Bash 4.0?  I can't see anything
relevant in the man page or NEWS file.

Re: MAILPATH stopped working after update to Bash 4.0

by Chet Ramey :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Nikos Chantziaras wrote:

> I have:
>
>   MAILPATH="/home/me/.maildir/new?You have new mail."
>   MAILCHECK=60
>
> Bash 3.2 was correctly telling me about new mail arriving.  However,
> after I updated to Bash 4.0, I constantly get a "You have new mail."
> message every minute even though I actually don't have new mail.  Has
> the mail notification feature changed in Bash 4.0?  I can't see anything
> relevant in the man page or NEWS file.

There was a small change made to the mail file initialization code, to
keep from dropping the first "new mail" notification.  (In April, 2007,
though, so you'd figure one of the testers would have caught a problem
before now.)

I don't use a maildir-aware mail program, but you can debug this by
setting a breakpoint in mailcheck.c:check_mail().

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    chet@...    http://cnswww.cns.cwru.edu/~chet/



Parent Message unknown Re: MAILPATH stopped working after update to Bash 4.0

by Nikos Chantziaras :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Chet Ramey wrote:

> Nikos Chantziaras wrote:
>> I have:
>>
>>   MAILPATH="/home/me/.maildir/new?You have new mail."
>>   MAILCHECK=60
>>
>> Bash 3.2 was correctly telling me about new mail arriving.  However,
>> after I updated to Bash 4.0, I constantly get a "You have new mail."
>> message every minute even though I actually don't have new mail.  Has
>> the mail notification feature changed in Bash 4.0?  I can't see anything
>> relevant in the man page or NEWS file.
> [...]
> I don't use a maildir-aware mail program, but you can debug this by
> setting a breakpoint in mailcheck.c:check_mail().

Learning to debug Bash is not in my todo list right now.  But if there's
anything else I can do I would be happy to.

Re: [PATCH] MAILPATH stopped working after update to Bash 4.0

by Evgeniy Dushistov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, May 26, 2009 at 04:11:23PM -0400, Chet Ramey wrote:

> Nikos Chantziaras wrote:
> > I have:
> >
> >   MAILPATH="/home/me/.maildir/new?You have new mail."
> >   MAILCHECK=60
> >
> > Bash 3.2 was correctly telling me about new mail arriving.  However,
> > after I updated to Bash 4.0, I constantly get a "You have new mail."
> > message every minute even though I actually don't have new mail.  Has
> > the mail notification feature changed in Bash 4.0?  I can't see anything
> > relevant in the man page or NEWS file.
>
> There was a small change made to the mail file initialization code, to
> keep from dropping the first "new mail" notification.  (In April, 2007,
> though, so you'd figure one of the testers would have caught a problem
> before now.)
>
> I don't use a maildir-aware mail program, but you can debug this by
> setting a breakpoint in mailcheck.c:check_mail().
>

I recently faced with the same problem, when package manager update
my bash from 3.x to 4.x.
I compared mailcheck.c from 3.2 and 4.0, and see only logic difference
in add_mail_file. When it function handle new file, it not read it's
date information as it was in 3.x, but set it to zero,
so I made such changes:

--- mailcheck-vanilla.c 2009-10-25 22:44:33.000000000 +0300
+++ mailcheck.c 2009-10-25 22:45:33.000000000 +0300
@@ -193,6 +193,7 @@ add_mail_file (file, msg)
 
   mailfiles[i] = alloc_mail_file (filename, msg);
   init_mail_file (i);
+  update_mail_file (i);
 
   return i;
 }


and at now I not see any problems,
comments?

--
/Evgeniy




Re: [PATCH] MAILPATH stopped working after update to Bash 4.0

by Chet Ramey :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Evgeniy Dushistov wrote:

> On Tue, May 26, 2009 at 04:11:23PM -0400, Chet Ramey wrote:
>> Nikos Chantziaras wrote:
>>> I have:
>>>
>>>   MAILPATH="/home/me/.maildir/new?You have new mail."
>>>   MAILCHECK=60
>>>
>>> Bash 3.2 was correctly telling me about new mail arriving.  However,
>>> after I updated to Bash 4.0, I constantly get a "You have new mail."
>>> message every minute even though I actually don't have new mail.  Has
>>> the mail notification feature changed in Bash 4.0?  I can't see anything
>>> relevant in the man page or NEWS file.
>> There was a small change made to the mail file initialization code, to
>> keep from dropping the first "new mail" notification.  (In April, 2007,
>> though, so you'd figure one of the testers would have caught a problem
>> before now.)
>>
>> I don't use a maildir-aware mail program, but you can debug this by
>> setting a breakpoint in mailcheck.c:check_mail().
>>
>
> I recently faced with the same problem, when package manager update
> my bash from 3.x to 4.x.
> I compared mailcheck.c from 3.2 and 4.0, and see only logic difference
> in add_mail_file. When it function handle new file, it not read it's
> date information as it was in 3.x, but set it to zero,

The change to use init_mail_file was intentional, but it doesn't set
the mod time and access time to 0.  It initializes a mailpath entry,
but doesn't call mailstat on the file until it's actually checking mail.
Changing it back to call update_mail_file defeats the purpose of the
change, which is to avoid calling mailstat and reading a potentially
very large maildir until MAILCHECK is set and we need to.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@...    http://cnswww.cns.cwru.edu/~chet/



Re: [PATCH] MAILPATH stopped working after update to Bash 4.0

by Nikos Chantziaras :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10/26/2009 04:16 AM, Chet Ramey wrote:

> Evgeniy Dushistov wrote:
>> On Tue, May 26, 2009 at 04:11:23PM -0400, Chet Ramey wrote:
>>> Nikos Chantziaras wrote:
>>>> I have:
>>>>
>>>>    MAILPATH="/home/me/.maildir/new?You have new mail."
>>>>    MAILCHECK=60
>>>>
>>>> Bash 3.2 was correctly telling me about new mail arriving.  However,
>>>> after I updated to Bash 4.0, I constantly get a "You have new mail."
>>>> message every minute even though I actually don't have new mail.
>>>> [...]
>>> There was a small change made to the mail file initialization code, to
>>> keep from dropping the first "new mail" notification.  [...]
>>>
>>> I don't use a maildir-aware mail program, but you can debug this by
>>> setting a breakpoint in mailcheck.c:check_mail().
>>
>> I recently faced with the same problem, when package manager update
>> my bash from 3.x to 4.x.
>> I compared mailcheck.c from 3.2 and 4.0, and see only logic difference
>> in add_mail_file. When it function handle new file, it not read it's
>> date information as it was in 3.x, but set it to zero,
>
> The change to use init_mail_file was intentional, but it doesn't set
> the mod time and access time to 0.  It initializes a mailpath entry,
> but doesn't call mailstat on the file until it's actually checking mail.
> Changing it back to call update_mail_file defeats the purpose of the
> change, which is to avoid calling mailstat and reading a potentially
> very large maildir until MAILCHECK is set and we need to.

It also seems to defeat the purpose of getting informed about new mail :P



Re: [PATCH] MAILPATH stopped working after update to Bash 4.0

by Evgeniy Dushistov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Oct 25, 2009 at 10:16:57PM -0400, Chet Ramey wrote:

> Evgeniy Dushistov wrote:
> > On Tue, May 26, 2009 at 04:11:23PM -0400, Chet Ramey wrote:
> >> Nikos Chantziaras wrote:
> >>> I have:
> >>>
> >>>   MAILPATH="/home/me/.maildir/new?You have new mail."
> >>>   MAILCHECK=60
> >>>
> >>> Bash 3.2 was correctly telling me about new mail arriving.  However,
> >>> after I updated to Bash 4.0, I constantly get a "You have new mail."
> >>> message every minute even though I actually don't have new mail.  Has
> >>> the mail notification feature changed in Bash 4.0?  I can't see anything
> >>> relevant in the man page or NEWS file.
> >> There was a small change made to the mail file initialization code, to
> >> keep from dropping the first "new mail" notification.  (In April, 2007,
> >> though, so you'd figure one of the testers would have caught a problem
> >> before now.)
> >>
> >> I don't use a maildir-aware mail program, but you can debug this by
> >> setting a breakpoint in mailcheck.c:check_mail().
> >>
> >
> > I recently faced with the same problem, when package manager update
> > my bash from 3.x to 4.x.
> > I compared mailcheck.c from 3.2 and 4.0, and see only logic difference
> > in add_mail_file. When it function handle new file, it not read it's
> > date information as it was in 3.x, but set it to zero,
>
> The change to use init_mail_file was intentional, but it doesn't set
> the mod time and access time to 0.  It initializes a mailpath entry,
> but doesn't call mailstat on the file until it's actually checking mail.
> Changing it back to call update_mail_file defeats the purpose of the
> change, which is to avoid calling mailstat and reading a potentially
> very large maildir until MAILCHECK is set and we need to.
>

So, at now you see the root of problem?

mailfiles[i]->access_time = mailfiles[i]->mod_time is setted
to something: last_time_mail_checked or shell_start_time,

then in check_mail mailstat was called and then
comparission of mtime and finfo.st_mtime was done,
of course they not the same, so bash report
that you have mail in every maildir and mailbox.

The possible solutions, that works in right way in compare with
current state and also do not call mailstat on start:

Index: bash-4.0/mailcheck.c
===================================================================
--- bash-4.0.orig/mailcheck.c
+++ bash-4.0/mailcheck.c
@@ -268,7 +268,7 @@ file_mod_date_changed (i)
   mtime = mailfiles[i]->mod_time;
 
   if ((mailstat (file, &finfo) == 0) && (finfo.st_size > 0))
-    return (mtime != finfo.st_mtime);
+    return (mtime < finfo.st_mtime);
 
   if (finfo.st_size == 0 && mailfiles[i]->file_size > 0)
     UPDATE_MAIL_FILE (i, finfo);

or:

Index: bash-4.0/mailcheck.c
===================================================================
--- bash-4.0.orig/mailcheck.c
+++ bash-4.0/mailcheck.c
@@ -425,6 +425,9 @@ check_mail ()
       if (*current_mail_file == '\0')
  continue;
 
+      if (!(mailfiles[i]->flags & MBOX_INITIALIZED))
+      update_mail_file (i);
+
       if (file_mod_date_changed (i))
  {
   int file_is_bigger;


--
/Evgeniy