Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: Ulrich Mueller <ulm@g.o>
Cc: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Unifying option passing conventions in the PMS
Date: Mon, 01 Sep 2014 16:47:13
Message-Id: 20140901184657.0d8a8117@pomiot.lan
In Reply to: Re: [gentoo-dev] Unifying option passing conventions in the PMS by Ulrich Mueller
1 Dnia 2014-09-01, o godz. 15:35:42
2 Ulrich Mueller <ulm@g.o> napisał(a):
3
4 > >>>>> On Mon, 1 Sep 2014, Michał Górny wrote:
5 >
6 > > 1. Options must precede positional parameters on the command-line.
7 > > Interspersing options and positional parameters is not allowed.
8 >
9 > > 2. Each short option must be specified as a separate parameter.
10 > > Specifying multiple short options in one parameter is not allowed.
11 >
12 > > 3. If a helper supports any options, then the positional parameters
13 > > may not resemble options. In particular, passing any positional
14 > > parameters beginning with '-' is not allowed.
15 >
16 > > 4. [optionally] If a helper supports any options, '--' option may be
17 > > used to terminate option parsing. All parameters following it will
18 > > be treated as positional parameters, and rule 3. doesn't apply to
19 > > parameters following '--'.
20 >
21 > > 5. Helpers should define both short and long variants for each
22 > > option they provide.
23 >
24 > > 6. If the option takes a parameter, it should be passed as
25 > > the parameter immediately following it. Concatenating option
26 > > and the parameter is not allowed. Interspersing multiple options
27 > > and their parameters is not allowed.
28 >
29 > There is a standard for options and their arguments [1]. It is
30 > implemented in the getopt(3) function in C and in the getopts(1)
31 > command, which is a bash builtin.
32
33 This standard does not support long options which makes it a poor
34 standard. Many of the current eclasses rely on long options. If we
35 decide not to support them, the policy couldn't really be applied to
36 eclasses and we wouldn't gain much. Still every developer would invent
37 his own rules.
38
39 The getopt_long() standard is much better. However, using it would
40 either require putting extra dependency in @system for small gain, or
41 reimplementing a huge option parser. And in the end, we will rather
42 limit the possibilities via policy because ebuilds will soon become
43 very unreadable.
44
45 > So if we are going to change anything with respect to option parsing
46 > in package manager commands, then lets please stick to these
47 > established guidelines, instead of inventing our own (at least partly)
48 > incompatible rules.
49
50 My rules are practically compatible with the getopt_long() guidelines,
51 only more strict. Ebuilds following them will be compatible with
52 getopt_long() parser. However, the stricter rules will allow them to
53 work with much simpler parser too.
54
55 The only incompatibility is that the rules don't apply to helpers
56 not supporting option parsing at all -- einfo, elog etc. where option
57 parsing is undesired and would. Plus the helpers that only pass options
58 through, like econf, emake.
59
60
61 --
62 Best regards,
63 Michał Górny

Attachments

File name MIME type
signature.asc application/pgp-signature