1 |
On Thu, Nov 7, 2019 at 3:31 PM Zac Medico <zmedico@g.o> wrote: |
2 |
> |
3 |
> On 11/7/19 10:22 AM, Mike Gilbert wrote: |
4 |
> > The --context option accepts an optional argument, but only if it is |
5 |
> > passed via --context=arg. The argparse module does not deal with this |
6 |
> > properly. |
7 |
> > |
8 |
> > To work around this, have argparse ignore this option, and filter out |
9 |
> > any remaining arguments that start with a hyphen. |
10 |
> > |
11 |
> > Bug: https://bugs.gentoo.org/699548 |
12 |
> > Signed-off-by: Mike Gilbert <floppym@g.o> |
13 |
> > --- |
14 |
> > bin/install.py | 8 +------- |
15 |
> > 1 file changed, 1 insertion(+), 7 deletions(-) |
16 |
> > |
17 |
> > diff --git a/bin/install.py b/bin/install.py |
18 |
> > index d3789ed96..e56475ff1 100755 |
19 |
> > --- a/bin/install.py |
20 |
> > +++ b/bin/install.py |
21 |
> > @@ -111,12 +111,6 @@ def parse_args(args): |
22 |
> > action="store_true", |
23 |
> > dest="no_target_directory" |
24 |
> > ) |
25 |
> > - parser.add_argument( |
26 |
> > - "--context", |
27 |
> > - "-Z", |
28 |
> > - action="store", |
29 |
> > - dest="context" |
30 |
> > - ) |
31 |
> > parser.add_argument( |
32 |
> > "--verbose", |
33 |
> > "-v", |
34 |
> > @@ -147,7 +141,7 @@ def parse_args(args): |
35 |
> > |
36 |
> > opts = parsed_args[0] |
37 |
> > files = parsed_args[1] |
38 |
> > - files = [f for f in files if f != "--"] # filter out "--" |
39 |
> > + files = [f for f in files if not f.startswith("-")] # filter unknown options |
40 |
> > |
41 |
> > return (opts, files) |
42 |
> > |
43 |
> > |
44 |
> |
45 |
> Technically, shouldn't we pass through any "files" that start with "-" |
46 |
> and come after the "--" separator? |
47 |
|
48 |
Ah, yes. I will revise it. |