diff options
author | Mike Gilbert <floppym@gentoo.org> | 2019-11-07 13:16:09 -0500 |
---|---|---|
committer | Mike Gilbert <floppym@gentoo.org> | 2019-11-08 10:59:47 -0500 |
commit | f6369a67d33fd5e95e02cf9b3cee41213a3b8804 (patch) | |
tree | e0346996370fa0cd43f815832e01fb201f3ad840 | |
parent | Revert "repoman: fix unsafe string interpolation (bug 699508)" (diff) | |
download | gentoo-portage-f6369a67d33fd5e95e02cf9b3cee41213a3b8804.tar.xz gentoo-portage-f6369a67d33fd5e95e02cf9b3cee41213a3b8804.zip |
install.py: ignore -Z / --context
The --context option accepts an optional argument, but only if it is
passed via --context=arg. The argparse module does not deal with this
properly.
To work around this, have argparse ignore this option, and filter out
any remaining arguments that start with a hyphen and do not occur after
a "--" delimiter.
Bug: https://bugs.gentoo.org/699548
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Reviewed-by: Zec Medico <zmedico@gentoo.org>
-rwxr-xr-x | bin/install.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/bin/install.py b/bin/install.py index d3789ed96..495534d33 100755 --- a/bin/install.py +++ b/bin/install.py @@ -112,12 +112,6 @@ def parse_args(args): dest="no_target_directory" ) parser.add_argument( - "--context", - "-Z", - action="store", - dest="context" - ) - parser.add_argument( "--verbose", "-v", action="store_true", @@ -143,11 +137,21 @@ def parse_args(args): # for known options in order for argparse to correctly # separate option arguments from file arguments in all # cases (it also allows for optparse compatibility). - parsed_args = parser.parse_known_args() + (opts, args) = parser.parse_known_args(args) + + files = [] + i = 0 + while i < len(args): + if args[i] == "--": + i += 1 + break + if not args[i].startswith("-"): + files.append(args[i]) + i += 1 - opts = parsed_args[0] - files = parsed_args[1] - files = [f for f in files if f != "--"] # filter out "--" + while i < len(args): + files.append(args[i]) + i += 1 return (opts, files) |