nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] [PATCH] scan message numbers from stdin

2008-08-18 14:53:45
Hi, everyone. I wrote a long message to Eric this morning with some points to the ones here.

On 8/18/2008 9:43 AM, Peter Maydell wrote:
I think that it would be nice if 'scan 4 1 2' actually output the messages
in the order stated on the command line.

On 8/18/2008 10:07 AM, norm(_at_)dad(_dot_)org wrote:
What about

  scan 1 1 2 2

which is now the same as

  scan 1 2


I don't know enough about the MH/nmh source code to be sure, but it seems that most/all utilities do some sort of checking and processing of their command-line arguments before the actual scanning/picking/showing/etc. takes place. (This comes from 25+ years of using MH, not from checking the source.) If I'm guessing correctly, this processing handles invalid message numbers, eliminates duplicates (as in Norm's example), and more -- to produce an ordered list of messages for scan/show/etc. to operate on. If the source code could be changed to do what Peter suggests (which I've often wished for!), I wonder if we'd lose a lot of the beneficial things that we've come to expect without (maybe) realizing that they were there.

Here's my message, FWIW.

Jerry

-------- Forwarded Message --------
Subject:        Re: [Nmh-workers] [PATCH] scan message numbers from stdin
Date:   Mon, 18 Aug 2008 09:04:05 -0700
From:   Jerry Peek <jpeek(_at_)jpeek(_dot_)com>
To:     Eric Gillespie <epg(_at_)pretzelnet(_dot_)org>
References:     
<31949(_dot_)1218843943(_at_)wundagore(_dot_)diplodocus(_dot_)org>


Hi, Eric --

....

When I saw the start of your message and your example of

pick whatever | scan -

I thought "what a great and obviously-needed fix!" Somewhere, though, inside the cobwebs of my brain ;-) I remembered doing something similar -- probably getting a list of message numbers from some script hackery -- and running into problems with the case when some of the messages in that list of numbers don't exist (anymore).

So I'm wondering what this patch does when a message number read from standard input refers to a message that doesn't exist. Does scan abort? Since scan (I guess) may have already produced some output at that point, what next? I'll try to explain myself by giving a similar example.

With most or all MH utilities, if you pass them a message range (like first:20 or 267-307) and/or a list of explicit message numbers, they work like this:

$ alias msgnums="scan -format '%(msg)'"
$ msgnums 220-228
220
221
222
223
224
$ !! 233
msgnums 220-228 233
scan: message 233 doesn't exist
$ !! 235
msgnums 220-228 233 235
scan: message 233 doesn't exist

The first call to scan, with the range 220-228, returns the list of messages in that range that actually exist right now: 220 through 224, but not 225 through 228. No errors there. In the second call to scan, I add the explicit message number 233 to the end of the argument list, and scan aborts without any output because that message number (that argument?) refers to a message that doesn't exist. In the third call, I add another invalid message number (235) to the end of the list, but scan doesn't complain about it; it aborted when it found that the previous argument (233) was invalid.

I guess I'm posing these questions (for your info, not because I think anything is "wrong" in your code... :I haven't even tried to test it!)

- when I feed input to "scan -", does it need to be a list of message numbers, one per line? Or can the arguments be a space-separated list of message numbers like this:

 $ echo 220 221 222 223 224 225 226 227 228 | scan -

- what happens when a message number is invalid? I guess that "scan -" will output the message numbers that are valid, up to the point where it encounters an invalid number, then print an error and abort? Or will it warn about each invalid message and produce output for all valid message number?

And should the above stuff be documented? (So much of the old MH behavior -- like the examples I show above -- wasn't documented, and people had to figure it out themselves. Maybe that's the best answer here too: if people wonder, let them try it.)

I hope this long ramble was some use. If it wasn't, no worries here! I just wanted to send it when it crossed my mind.

Jerry



_______________________________________________
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>