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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 8D12815800A for ; Tue, 18 Jul 2023 06:28:28 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D3091E08D1; Tue, 18 Jul 2023 06:28:27 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BF8E9E08D1 for ; Tue, 18 Jul 2023 06:28:27 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C5A93340D8E for ; Tue, 18 Jul 2023 06:28:26 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 081FEB8B for ; Tue, 18 Jul 2023 06:28:25 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1689661612.68e1d30bcd977396f1db41be800f0a80ff03467a.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: main.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 68e1d30bcd977396f1db41be800f0a80ff03467a X-VCS-Branch: master Date: Tue, 18 Jul 2023 06:28:25 +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: e3cd0f64-54f0-4e31-9562-ca6c97cd74f3 X-Archives-Hash: aa06fd83d03a2f2253ddc0e26566e9c9 commit: 68e1d30bcd977396f1db41be800f0a80ff03467a Author: Fabian Groffen gentoo org> AuthorDate: Tue Jul 18 06:26:52 2023 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Tue Jul 18 06:26:52 2023 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=68e1d30b main: init quiet early for repo checks For as long as we will pre-load all profile information at every q invocation, respect -q flag so warnings in that code can be suppressed. Bug: https://bugs.gentoo.org/735134 Signed-off-by: Fabian Groffen gentoo.org> main.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index 010675e..7225eed 100644 --- a/main.c +++ b/main.c @@ -979,14 +979,6 @@ initialize_portage_env(void) const char *configroot = getenv("PORTAGE_CONFIGROOT"); char *primary_overlay = NULL; - /* ensure color strings are initialised, code below here may use - * e.g. warn which uses them */ - color_clear(); - - /* set quiet early in the game, bug #735134 */ - if (getenv("PORTAGE_QUIET") != NULL) - setup_quiet(); - /* initialize all the properties with their default value */ for (i = 0; vars_to_read[i].name; ++i) { var = &vars_to_read[i]; @@ -1242,6 +1234,7 @@ int main(int argc, char **argv) { struct stat st; struct winsize winsz; + int i; warnout = stderr; IF_DEBUG(init_coredumps()); @@ -1271,7 +1264,29 @@ int main(int argc, char **argv) } vars_to_read[7].default_value = (char *)nocolor; /* NOCOLOR */ + /* We can use getopt here, but only in POSIX mode (which stops at + * the first non-option argument) because otherwise argv is + * modified, this basically sulks, because ideally we parse and + * handle the common options here. Because we are parsing profiles + * and stuff at this point we need -q for bug #735134, so do lame + * matching for that */ + for (i = 1; i < argc; i++) { + if (argv[i] != NULL && argv[i][0] == '-' && + (argv[i][1] == 'q' || strcmp(&argv[i][1], "-quiet") == 0)) + { + setup_quiet(); + } + } + /* same for env-based fallback */ + if (getenv("PORTAGE_QUIET") != NULL) + setup_quiet(); + + /* ensure color strings are initialised, early code here may use + * e.g. warn which uses them */ + color_clear(); + initialize_portage_env(); optind = 0; + quiet = 0; return q_main(argc, argv); }