nmh-workers
[Top][All Lists]
Advanced

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

[Nmh-workers] Inconsistencies in Checking if a Folder is Empty.


From: Ralph Corderoy
Subject: [Nmh-workers] Inconsistencies in Checking if a Folder is Empty.
Date: Thu, 19 May 2005 17:29:52 +0100

Hi,

I wanted to check if a folder had any messages.  Along the way I tried
these commands and was surprised by the results.

    $ folder +junk last; echo $?
    junk+ has 9 messages  (1-9); cur=9.
    0

Fine.

    $ folder +junk 100; echo $?
    folder: message 100 doesn't exist
    junk+ has 9 messages  (1-9); cur=9.
    0

It's not an error?  folder is meant to set the current folder and/or
message.

    $ mhpath +junk last; echo $?
    /home/ralph/mail/junk/9
    0

Fine.

    $ mhpath +junk 999; echo $?
    mhpath: message 999 out of range 1-9
    1

OK, an error this time since 999 is outside the range 1-9.

    $ mhpath +junk 4; echo $?
    /home/ralph/mail/junk/4
    0
    $ ls /home/ralph/mail/junk/4
    ls: /home/ralph/mail/junk/4: No such file or directory
    $ 

But it isn't an error when 4 doesn't exist in the range 1-9.  Either
mhpath should generate the path the message would have, if it were to
exist, or it shouldn't generate it if it doesn't currently exist.  At
the moment it does a bit of both.

(I finally settled on

    mhpath +junk first >/dev/null 2>&1

since $? is 0 iff there's a message and 1 iff there isn't.)

Cheers,


Ralph.





reply via email to

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