Re: MUAs and timestamps, was Re: how to grep without changing timestamps?
>>>>> D-Man writes:
d> | How is mutt (or any other MUA) meant to do it then?
d> |
d> By checking the file itself for new messages, rather than
d> relying on the timestamp. Some MUA's handle new messages in
d> folders better. (ie, you can open up the mailbox, not read
d> anything, and it still says new -- mutt doesn't)
Only now, when the user has 1e6 messages in his inbox because he
never deletes any, he opens mutt and then goes on his coffee break and
gets back before mutt is done scanning the messages. Also, where is
mutt supposed to keep the information about which messages were
previously in the folder?
d> All-in-all though it's not such a bad system (for mutt). It
d> probably solves a lot of headaches with locks and other
d> processes trying to write to the mbox as mutt reads to
d> determine if something is new or not.
What is "it" here? Futzing around scanning the mailbox or doing a
stat()? I hope you mean the latter.
Incidentally, it appears from the stat(2) man page that a solution
to this problem might be unmounting, mounting with the option
"noatime", and then remounting without that option. It also appears
that 'touch' can change the access time of the file with the -a flag.
But I think I'm coming in on the end of this thread and that might
have already been suggested. Also, if you know that your mailbox has
new mail, you can
echo "" >> $mailbox
which has the effect of making the modification time greater than the
access time, which will make mutt put an N next to the mailbox. This
suggests a script, which isn't perfect but works:
#!/bin/bash
if [ $# -ne "2" ]; then
echo "usage: $0 pattern file"
exit 1
fi
atime=`stat -t $2 | cut -f 12 -d " "`
mtime=`stat -t $2 | cut -f 13 -d " "`
makenew=false
if [ $atime -lt $mtime ]; then
makenew=true
fi
grep $1 $2
if $makenew; then
sleep 2 # make sure that the atime and mtime are on different
# seconds
echo "" >> $2
fi
Cheers,
Chris
--
Got jag? http://www.tribsoft.com
Reply to: