[Top][All Lists]

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

Re: [Nmh-workers] Redoing argument processing

From: Kevin Cosgrove
Subject: Re: [Nmh-workers] Redoing argument processing
Date: Thu, 17 Jan 2013 13:01:38 -0800

On 17 January 2013 at 15:37, Ken Hornstein <address@hidden> 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!


reply via email to

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