RPM Community Forums

Mailing List Message of <popt-devel>

Support for variable number of arguments in popt

From: Christian Schmidt <schmidt@digadd.de>
Date: Wed 07 Sep 2011 - 10:44:13 CEST
Message-ID: <4E672EDD.5010600@digadd.de>
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 ...

The reason for the space separated lists is simply shell expansion.
Given existing device nodes you could write <program> -r /dev/sd[ab] -m
/dev/sd[cd] -b 16m ... to reach the same. Similar expansion could be
done with {a..z} or wildcard patterns. However this is not a case of
leftover arguments since the context (in the above example, -r or -m) is
relevant.

So far I tried to use POPT_ARG_ARGV (which expects one -r/-m for each
argument) as well as poptPeekArg from within a r/m handler to look at
the next word in the command line. However, poptPeekArg only seems to
work after all arguments are parsed.

Is there a way to realize what I'm trying within the current version of
popt, and if not, would there be any interest (or chance of being added)
implementing a POP_ARG_LIST that would act like POPT_ARG_ARGV, but take
all arguments until the next parameter starting with a "-"?

Regards,
Christian
Received on Wed Sep 7 11:55:06 2011
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.