nmh-workers
[Top] [All Lists]

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

2005-05-19 09:30:41

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.



_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
http://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>