Dnia 2014-09-01, o godz. 15:35:42
Ulrich Mueller <[email protected]> napisał(a):

> >>>>> On Mon, 1 Sep 2014, Michał Górny wrote:
> 
> > 1. Options must precede positional parameters on the command-line.
> > Interspersing options and positional parameters is not allowed.
> 
> > 2. Each short option must be specified as a separate parameter.
> > Specifying multiple short options in one parameter is not allowed.
> 
> > 3. If a helper supports any options, then the positional parameters
> > may not resemble options. In particular, passing any positional
> > parameters beginning with '-' is not allowed.
> 
> > 4. [optionally] If a helper supports any options, '--' option may be
> > used to terminate option parsing. All parameters following it will
> > be treated as positional parameters, and rule 3. doesn't apply to
> > parameters following '--'.
> 
> > 5. Helpers should define both short and long variants for each
> > option they provide.
> 
> > 6. If the option takes a parameter, it should be passed as
> > the parameter immediately following it. Concatenating option
> > and the parameter is not allowed. Interspersing multiple options
> > and their parameters is not allowed.
> 
> There is a standard for options and their arguments [1]. It is
> implemented in the getopt(3) function in C and in the getopts(1)
> command, which is a bash builtin.

This standard does not support long options which makes it a poor
standard. Many of the current eclasses rely on long options. If we
decide not to support them, the policy couldn't really be applied to
eclasses and we wouldn't gain much. Still every developer would invent
his own rules.

The getopt_long() standard is much better. However, using it would
either require putting extra dependency in @system for small gain, or
reimplementing a huge option parser. And in the end, we will rather
limit the possibilities via policy because ebuilds will soon become
very unreadable.

> So if we are going to change anything with respect to option parsing
> in package manager commands, then lets please stick to these
> established guidelines, instead of inventing our own (at least partly)
> incompatible rules.

My rules are practically compatible with the getopt_long() guidelines,
only more strict. Ebuilds following them will be compatible with
getopt_long() parser. However, the stricter rules will allow them to
work with much simpler parser too.

The only incompatibility is that the rules don't apply to helpers
not supporting option parsing at all -- einfo, elog etc. where option
parsing is undesired and would. Plus the helpers that only pass options
through, like econf, emake.


-- 
Best regards,
Michał Górny

Attachment: signature.asc
Description: PGP signature

Reply via email to