From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 810FE138334 for ; Fri, 8 Nov 2019 16:02:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C30A3E097B; Fri, 8 Nov 2019 16:02:10 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id AD46AE0992 for ; Fri, 8 Nov 2019 16:02:10 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 55DEE34CA9D for ; Fri, 8 Nov 2019 16:02:08 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5FDCC26C for ; Fri, 8 Nov 2019 16:02:06 +0000 (UTC) From: "Mike Gilbert" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Gilbert" Message-ID: <1573228787.f6369a67d33fd5e95e02cf9b3cee41213a3b8804.floppym@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/install.py X-VCS-Directories: bin/ X-VCS-Committer: floppym X-VCS-Committer-Name: Mike Gilbert X-VCS-Revision: f6369a67d33fd5e95e02cf9b3cee41213a3b8804 X-VCS-Branch: master Date: Fri, 8 Nov 2019 16:02:06 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 9ea300e1-dfec-4942-91c4-6d43f9e0db5d X-Archives-Hash: 41964dbd44092fed3587720ad72ffd9d commit: f6369a67d33fd5e95e02cf9b3cee41213a3b8804 Author: Mike Gilbert gentoo org> AuthorDate: Thu Nov 7 18:16:09 2019 +0000 Commit: Mike Gilbert gentoo org> CommitDate: Fri Nov 8 15:59:47 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=f6369a67 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 gentoo.org> Reviewed-by: Zec Medico gentoo.org> bin/install.py | 24 ++++++++++++++---------- 1 file 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 @@ -111,12 +111,6 @@ def parse_args(args): action="store_true", dest="no_target_directory" ) - parser.add_argument( - "--context", - "-Z", - action="store", - dest="context" - ) parser.add_argument( "--verbose", "-v", @@ -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)