On 17 January 2013 at 15:37, Ken Hornstein <kenh(_at_)pobox(_dot_)com> wrote:
Last year there was a discussion on nmh-workers about why you can't have
a moreproc like "less -f". See the thread here:
http://lists.nongnu.org/archive/html/nmh-workers/2012-05/msg00140.html
After some discussion, I think we settled on this:
- 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
The last one is actually trickier than I first thought.
A lot of nmh stuff wants to add arguments to an existing argv[] array.
We could pass that built-up argv array into the subroutine that takes care
of that (I'm calling it argsplit()) and have it return the formatted argv[]
array, but I'm wondering what the last case would look like. I thought
at first that maybe we could do:
/bin/sh -c 'proc arg1 arg2 arg3'
and so on, but that would involve an extra level of shell interpretation.
I then thought about
/bin/sh -c 'proc "$@" arg1 arg2 arg3
Only problem with that is that "arg1" gets put into $0, which doesn't get
expanded by $@, so it should really be:
/bin/sh -c 'proc "$@"' dummyarg arg1 arg2 arg3
What do others think about this? Anything I'm missing?
I like where you're going with this.
In the past I've created scripts that contained the args, then
referenced the script from the mail progs. That's kind of a nuisance.
Thanks for thinking about it!
--
Kevin
_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers