ken 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'm not clear on what's so wrong with the above. i assume proc would
be expanded, so you'd end up with
/bin/sh -c 'less -aics arg1 arg2 arg3'
or
/bin/sh -c '~pgf/foo arg1 arg2 arg3'
i'm missing the "extra level of interpretation" you're thinking of.
paul
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?
--Ken
_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers
=---------------------
paul fox, pgf(_at_)foxharp(_dot_)boston(_dot_)ma(_dot_)us (arlington, ma,
where it's 28.9 degrees)
_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers