RPM Community Forums

Mailing List Message of <popt-devel>

Re: Support for variable number of arguments in popt

From: Jeff Johnson <n3npq@mac.com>
Date: Wed 07 Sep 2011 - 18:41:34 CEST
Message-id: <28076114-8189-4298-B633-7D313BE7F422@mac.com>

On Sep 7, 2011, at 12:30 PM, Wichmann, Mats D wrote:

> 
> 
> On Wed, Sep 7, 2011 at 9:16 AM, Jeff Johnson <n3npq@mac.com> wrote:
> 
> On Sep 7, 2011, at 4:44 AM, Christian Schmidt wrote:
> 
> > Hi,
> >
> > I'm trying to parse a command line that can contain multiple variable
> > number of arguments for a parameter, e.g.
> >
> > <program> -r /dev/sda /dev/sdb -m /dev/sdc /dev/sdd -b 16m 
> >
> 
> Traditionally, uglix was designed with the model
>        PROGRAM OPTIONS ARGUMENTS
> and that is captured in strict POSIX (and still common on *BSD systems iirc).
> 
> The default option processing enhances --options=arg to take the "next"
> item, and there is the "=" that has been added to introduce some form
> of "stickiness".
> 
> What you are seeking with multiple arguments to a single option
> (and I understand well why you are attempting) isn't well supported
> anywhere afaik. The usual solution is to embed white space within
> quotes like
> 
>        <program> -r "/dev/sda /dev/sdb" -m "/dev/sdc /dev/sdd" -b 16m
> 
> 
> there's some precedent (not a lot) for using a separator other than space 
> for this purpose, often a comma since it happens to be neutral to the
> shell.  as in:
> 
> --optionlist=foo,bar,baz
> 

Yup. A comma separated list is actually what POPT uses for its Bloom filter
implementation, where a series of comma separated strings
are parsed as keys into a set container for arbitrary opaque strings
that can be used/testsed through a set membership mechanism.

Implemented here
	#define POPT_ARG_BITSET         16U+14U /*!< arg ==> bit set *
where arg is a comma separated set of strings.

There really isn't any guidance on a "standard" compliant solution.

Unless POSIX is mandating ',' as a separator somehow  which would
be truly daft *insanity* imho ;-)


> 
> if you use space, semicolon, etc. you do need to quote it.
> 

And these are shell, not POPT, uglix derived restrictions of course.

73 de Jeff
Received on Wed Sep 7 18:42:08 2011
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.