nmh-workers
[Top][All Lists]
Advanced

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

[Nmh-workers] Redoing argument processing


From: Ken Hornstein
Subject: [Nmh-workers] Redoing argument processing
Date: Thu, 17 Jan 2013 15:37:54 -0500

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?

--Ken



reply via email to

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