bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mail check fails when first mail creates new mail file


From: Michael Mueller
Subject: mail check fails when first mail creates new mail file
Date: Sat, 18 Sep 2004 14:36:14 +0200
User-agent: Mozilla/5.0

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' -DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -g uname output: Linux m1 2.6.4-52-default #1 Wed Sep 15 14:02:03 CEST 2004 i686 i686 i386 GNU/Linux
Machine Type: i686-pc-linux-gnu

Bash Version: 2.05b
Patch Level: 0
Release Status: release

Description:

        If my $MAIL file does not exist (after I deleted all mails) and
        a new mail arrives, bash does not output a

                You have new mail in $MAIL

        as it used to do in older versions (quite a while ago). Only
        when the second mail arrives I am notified.

        Having no $MAIL file is normal after deleting all mail using
        /usr/bin/mail.

Repeat-By:

    MAIL=/var/spool/mail/michaelm
    $ MAILCHECK=0   # check for mail before next prompt
    $ mail
    No mail for michaelm
    $ ls -l $MAIL
    /bin/ls: /var/spool/mail/michaelm: No such file or directory
    $ # send some mail to myself.
    $ mail michaelm
    Subject: t
    .
    EOT
    $ ls -lu $MAIL; ls -l $MAIL
    -rw-------  1 michaelm users 591 Sep 18 13:11 /var/spool/mail/michaelm
    -rw-------  1 michaelm users 591 Sep 18 13:11 /var/spool/mail/michaelm
    $
    $ # mail check failed. I have new mail.
    $ # send another mail.
    $ mail michaelm
    Subject: t2
    .
    EOT
    $
    You have new mail in /var/spool/mail/michaelm
    $

Fix:

    This is caused by this code in mailcheck.c, function check_mail:

          /* If the user has just run a program which manipulates the
             mail file, then don't bother explaining that the mail
             file has been manipulated.  Since some systems don't change
             the access time to be equal to the modification time when
             the mail in the file is manipulated, check the size also.If
             the file has not grown, continue. */
          if ((atime >= mtime) || !file_is_bigger)
            continue;

    In bash-1.14.7 This used to be:

        if ((atime >= mtime) && !file_is_bigger)

    I'm not sure when and why the && was changed into ||.

    If mail is used to delete all mails, it deletes the $MAIL file. If
    the first mail arrives, $MAIL is recreated with atime == mtime and
    bash skips the mail check.

    I don't know what was bad about the old code. But I changed it into:

        if ((atime > mtime) || (atime == mtime && !file_is_bigger))
            continue;

    This might be even better.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]