nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] Redoing argument processing

2013-01-18 07:43:10
oliver wrote:
You wrote:

/bin/sh -c 'proc "$@"' dummyarg arg1 arg2 arg3

What do others think about this?  Anything I'm missing?

 ...

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

couldn't one just skip the whole "what's a shell metacharacter these days?"
issue, and just always go for door #3?

paul


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
stripped.
  
Oliver


=---------------------
 paul fox, pgf(_at_)foxharp(_dot_)boston(_dot_)ma(_dot_)us (arlington, ma, 
where it's 13.6 degrees)

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

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