[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nmh-workers] Redoing argument processing
From: |
Paul Fox |
Subject: |
Re: [Nmh-workers] Redoing argument processing |
Date: |
Thu, 17 Jan 2013 19:29:56 -0500 |
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
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/nmh-workers
=---------------------
paul fox, address@hidden (arlington, ma, where it's 28.9 degrees)
- Re: [Nmh-workers] Redoing argument processing, (continued)
Re: [Nmh-workers] Redoing argument processing, Ralph Corderoy, 2013/01/17
Re: [Nmh-workers] Redoing argument processing,
Paul Fox <=
Re: [Nmh-workers] Redoing argument processing, Oliver Kiddle, 2013/01/18
Re: [Nmh-workers] Redoing argument processing, Ken Hornstein, 2013/01/18