[Top][All Lists]

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

Re: [Nmh-workers] Redoing argument processing

From: Oliver Kiddle
Subject: Re: [Nmh-workers] Redoing argument processing
Date: Fri, 18 Jan 2013 11:41:06 +0100

You wrote:
> /bin/sh -c 'proc "$@"' dummyarg arg1 arg2 arg3
> What do others think about this?  Anything I'm missing?

Seems like a nice trick to me. I like how it ensures expansion of any
arguments from .mh_profile without doing expansion on further arguments
provided by nmh.

I've thought about it and tried things out on different shells and can't
see anything you're missing but it's hard to be sure.

It would enable some hacks like using a proc that references "$@"
separately, semi-colons and pipe-lines and possibly finishing with ;: to
ignore the final "$@".

It might be tricky for the entries for mime types and character sets.
This was done to make it easy to run a command for the mime type in an
xterm setup for the character set. Nowadays, I use a script which
normally uses iconv but for some commands it passes the character set as
a parameter (e.g. w3m's -I option). We probably ought to do the iconv
internally and have a % escape for the input character set.

> - If "proc" has no spaces or shell metacharacters, treat normally.
> - If "proc" has spaces in it, space-split it and have each word put into
>   it's own index in the argv[] array.
> - If "proc" contains shell metacharacters, send it to /bin/sh -c

I'd be tempted to be lazy and not bother with the middle one of those.
You have to think about tabs and newlines, not just spaces.

What would you do about trailing whitespace? It probably shouldn't count
for selecting the second option instead of the first and should just be

reply via email to

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