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 30AB813835A for ; Sat, 20 Feb 2021 12:07:03 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 45FE3E083D; Sat, 20 Feb 2021 12:07:02 +0000 (UTC) Received: from smtp.gentoo.org (mail.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 E4F59E081A for ; Sat, 20 Feb 2021 12:07:01 +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 4159B33BF0F for ; Sat, 20 Feb 2021 12:06:59 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id BB5894E9 for ; Sat, 20 Feb 2021 12:06:56 +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: <1613822730.530f841aa8f7f38a72f4577863a3dcad8a21961f.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qwhich.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 530f841aa8f7f38a72f4577863a3dcad8a21961f X-VCS-Branch: master Date: Sat, 20 Feb 2021 12:06:56 +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: 25ed8da3-3674-4ff2-b53f-0247fe4d680f X-Archives-Hash: 25d1f809361c0d0513e69d6ca6d7a4ea commit: 530f841aa8f7f38a72f4577863a3dcad8a21961f Author: Fabian Groffen gentoo org> AuthorDate: Sat Feb 20 12:05:30 2021 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Sat Feb 20 12:05:30 2021 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=530f841a qwhich: add options to skip virtual and acct-* categories This allows to make an alias like this sort of working: cd $(qwhich -dTA ) Signed-off-by: Fabian Groffen gentoo.org> qwhich.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/qwhich.c b/qwhich.c index 2119466..05ea064 100644 --- a/qwhich.c +++ b/qwhich.c @@ -19,17 +19,19 @@ #include "atom.h" #include "tree.h" -#define QWHICH_FLAGS "IbtpdRflF:" COMMON_FLAGS +#define QWHICH_FLAGS "IbtpdRflTAF:" COMMON_FLAGS static struct option const qwhich_long_opts[] = { - {"vdb", no_argument, NULL, 'I'}, - {"binpkg", no_argument, NULL, 'b'}, - {"tree", no_argument, NULL, 't'}, - {"pretty", no_argument, NULL, 'p'}, - {"dir", no_argument, NULL, 'd'}, - {"repo", no_argument, NULL, 'R'}, - {"first", no_argument, NULL, 'f'}, - {"latest", no_argument, NULL, 'l'}, - {"format", a_argument, NULL, 'F'}, + {"vdb", no_argument, NULL, 'I'}, + {"binpkg", no_argument, NULL, 'b'}, + {"tree", no_argument, NULL, 't'}, + {"pretty", no_argument, NULL, 'p'}, + {"dir", no_argument, NULL, 'd'}, + {"repo", no_argument, NULL, 'R'}, + {"first", no_argument, NULL, 'f'}, + {"latest", no_argument, NULL, 'l'}, + {"novirtual", no_argument, NULL, 'T'}, + {"noacct", no_argument, NULL, 'A'}, + {"format", a_argument, NULL, 'F'}, COMMON_LONG_OPTS }; static const char * const qwhich_opts_help[] = { @@ -41,6 +43,8 @@ static const char * const qwhich_opts_help[] = { "Print repository name instead of path for tree/overlay matches", "Stop searching after first match (implies -l)", "Only return latest version for each match", + "Skip virtual category", + "Skip acct-user and acct-group categories", "Print matched using given format string", COMMON_OPTS_HELP }; @@ -57,6 +61,8 @@ struct qwhich_mode { char print_repo:1; char match_first:1; char match_latest:1; + char skip_virtual:1; + char skip_acct:1; const char *fmt; }; @@ -91,6 +97,8 @@ int qwhich_main(int argc, char **argv) case 'R': m.print_repo = true; break; case 'f': m.match_first = true; break; case 'l': m.match_latest = true; break; + case 'T': m.skip_virtual = true; break; + case 'A': m.skip_acct = true; break; case 'F': m.fmt = optarg; break; } } @@ -167,9 +175,11 @@ int qwhich_main(int argc, char **argv) } array_for_each(atoms, i, atom) { - tmc = tree_match_atom(t, atom, TREE_MATCH_DEFAULT | - (m.match_latest ? TREE_MATCH_LATEST : 0) | - (m.match_first ? TREE_MATCH_FIRST : 0)); + tmc = tree_match_atom(t, atom, + (m.match_latest ? TREE_MATCH_LATEST : 0 ) | + (m.match_first ? TREE_MATCH_FIRST : 0 ) | + (m.skip_virtual ? 0 : TREE_MATCH_VIRTUAL) | + (m.skip_acct ? 0 : TREE_MATCH_ACCT )); for (tmcw = tmc; tmcw != NULL; tmcw = tmcw->next) { if (m.print_atom) { printf("%s\n", atom_format(m.fmt, tmcw->atom));