From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 28 09:55:50 2021 Received: (at submit) by debbugs.gnu.org; 28 Dec 2021 14:55:50 +0000 Received: from localhost ([127.0.0.1]:47175 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2DtF-0008KX-Ng for submit@debbugs.gnu.org; Tue, 28 Dec 2021 09:55:50 -0500 Received: from lists.gnu.org ([209.51.188.17]:45406) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2DtD-0008KQ-CB for submit@debbugs.gnu.org; Tue, 28 Dec 2021 09:55:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2DtC-0000cs-UG for bug-grep@gnu.org; Tue, 28 Dec 2021 09:55:47 -0500 Received: from [2607:f8b0:4864:20::332] (port=36800 helo=mail-ot1-x332.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2DtB-0006jq-4j for bug-grep@gnu.org; Tue, 28 Dec 2021 09:55:46 -0500 Received: by mail-ot1-x332.google.com with SMTP id s21-20020a05683004d500b0058f585672efso19898881otd.3 for ; Tue, 28 Dec 2021 06:55:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=eQ8j9ZisC7531v5hqP3VpcWRyZ+E4x17NdsUWvUB354=; b=hqmnNqY3JC26+YOuknJgZBMlFQZlWMJuJIEFZ1//Y99y4uGUsUpX1vJBt+9l01y/G+ 7mAM6eFsfsSWhyQOgMH6NJkZXnMoNnOSgJVH8iI2j/mS5UlhpthNYdF3GjgR9Zvxo/JN Y6L4ALXNrBSNIk1BPidApSklhB8tas3pj4GTJwg4JlZXrbwCF/h6xqCe/GRZS8xdyWex I1QDp+Nuby9+lwdLvRbuGBjlUa343cQaj7skvfOLit64ciEF/14ubjU/iM59sUxBIVr7 ft9PMJiwqzSXJcwDRxlltUmhlGHQyij0gkUuiG6HwoVOcBmm8BWrwN90Uq83mZ6xn5pJ Hzeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=eQ8j9ZisC7531v5hqP3VpcWRyZ+E4x17NdsUWvUB354=; b=6pexRRInTahOLJCcnegKJMUozVBPfh2I9aqYz5Jufbg/rgodpKS4UTLJ5AKMc0aTP1 7ygn1GOx1t8HnHtGUKcKOxq6BqIP+8uG8ddX0AC5ISN1dzulSecDp1SWdST5sQhrE9Ha CH2brKB5QiVcGIUlPwCyL7GhwP8WvHERYKv7aJGKlOS7kV55ojygUf8aPT15l91fvXo6 6JIsnI013iakrS0NBCsq94k5j1oDJd7mGAVI+Sv4FHaha7EvjOco2uLmIBpdWgRtY9SF f2O79X6nhvzqp+NQmYU3L04nQsDAiMgTooyP8jsiOAMa2C12s11GU0lHvt4Ns11oDFb4 B87w== X-Gm-Message-State: AOAM533PXMyzpHkRc7D6aUt16zbUV/+XH4JXqpuBo8Gz+i8NlhFBILnx g34+k06vOcDiSvjA617Rm+wgx6bsmNUXQ5RIlCn/2B/c5Chzew== X-Google-Smtp-Source: ABdhPJypBjJDDaxjeSfAhWc8FwUMTZSLUKXsX28sdlp2coXqVOS2NQuLXdlBEU1KXKodmEV45zcqTWmMH6b82cp9N2Q= X-Received: by 2002:a9d:200f:: with SMTP id n15mr15455863ota.66.1640703343246; Tue, 28 Dec 2021 06:55:43 -0800 (PST) MIME-Version: 1.0 From: Kevin Connor Arpe Date: Tue, 28 Dec 2021 22:55:32 +0800 Message-ID: Subject: git grep feature: boolean logic To: bug-grep@gnu.org Content-Type: multipart/alternative; boundary="000000000000f4bf7b05d4360333" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::332 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::332; envelope-from=kevinarpe@gmail.com; helo=mail-ot1-x332.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --000000000000f4bf7b05d4360333 Content-Type: text/plain; charset="UTF-8" Hello, Recently, I was stumped with a difficult grep problem: I needed to filter files containing more than one regex (think: logical-and). I didn't know how to do this using only a single invocation of GNU grep. (Please correct me if I am wrong.) A bunch of Googling led me to discover that git has a grep sub-command that implements boolean logic with and/or/not/parens operators. Manpage: https://git-scm.com/docs/git-grep, Source: https://github.com/git/git/blob/master/grep.c At the moment, it's not possible to use git grep very well outside of git repositories. There are some issues around absolute and relative paths, plus "git working directory". Eventually, I settled on writing a crude shell script that wraps GNU grep to provide similar functionality. However, I am aware of its inefficiency, as it requires multiple invocations of grep. Are people aware of this very cool grep feature with boolean logic? I tried to search the GNU grep message archive, but I didn't see any discussion about it. I'm curious what the GNU grep team thinks about this feature. Kind regards, Kevin Arpe Hongkong --000000000000f4bf7b05d4360333 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,

Recently, I was stumped with a d= ifficult grep problem: I needed to filter files containing more than one re= gex (think: logical-and).=C2=A0 I didn't know how to do this using only= a single invocation of GNU grep.=C2=A0 (Please correct me if I am wrong.)<= /div>

A bunch of Googling led me to discover that git ha= s a grep sub-command that implements boolean logic with and/or/not/parens o= perators.=C2=A0 Manpage:=C2=A0https://git-scm.com/docs/git-grep, Source:=C2=A0https://github.com/gi= t/git/blob/master/grep.c

At the moment, it'= ;s not possible to use git grep very well outside of git repositories.=C2= =A0 There are some issues around absolute and relative paths, plus "gi= t working directory".

Eventually, I settled o= n writing a crude shell script that wraps GNU grep to provide similar funct= ionality.=C2=A0 However, I am aware of its inefficiency, as it requires mul= tiple invocations of grep.

Are people aware=C2=A0o= f this very cool grep feature with boolean=C2=A0logic?=C2=A0 I tried to sea= rch the GNU grep message archive, but I didn't see any discussion about= it.=C2=A0 I'm curious what the GNU grep team thinks about this feature= .

Kind regards,
Kevin Arpe
Hongkong
--000000000000f4bf7b05d4360333-- From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 28 10:44:19 2021 Received: (at 52851) by debbugs.gnu.org; 28 Dec 2021 15:44:19 +0000 Received: from localhost ([127.0.0.1]:47240 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2EeB-00017w-42 for submit@debbugs.gnu.org; Tue, 28 Dec 2021 10:44:19 -0500 Received: from freefriends.org ([96.88.95.60]:34640) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2Ee8-00017j-Lz for 52851@debbugs.gnu.org; Tue, 28 Dec 2021 10:44:17 -0500 X-Envelope-From: arnold@skeeve.com Received: from freefriends.org (freefriends.org [96.88.95.60]) by freefriends.org (8.14.7/8.14.7) with ESMTP id 1BSFiEgl009253 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Dec 2021 08:44:15 -0700 Received: (from arnold@localhost) by freefriends.org (8.14.7/8.14.7/Submit) id 1BSFiEbV009252; Tue, 28 Dec 2021 08:44:14 -0700 From: arnold@skeeve.com Message-Id: <202112281544.1BSFiEbV009252@freefriends.org> X-Authentication-Warning: frenzy.freefriends.org: arnold set sender to arnold@skeeve.com using -f Date: Tue, 28 Dec 2021 08:44:14 -0700 To: kevinarpe@gmail.com, 52851@debbugs.gnu.org Subject: Re: bug#52851: git grep feature: boolean logic References: In-Reply-To: User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 52851 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi. You may want a different tool: awk '/pattern1/ && /pattern2/' ... awk '/pattern1/ || /pattern2/' ... awk '/pattern1/ && !/pattern2/' ... And so on. Seems much easier than stuffing boolean logic into grep. Just a thought, Arnold Kevin Connor Arpe wrote: > Hello, > > Recently, I was stumped with a difficult grep problem: I needed to filter > files containing more than one regex (think: logical-and). I didn't know > how to do this using only a single invocation of GNU grep. (Please correct > me if I am wrong.) > > A bunch of Googling led me to discover that git has a grep sub-command that > implements boolean logic with and/or/not/parens operators. Manpage: > https://git-scm.com/docs/git-grep, Source: > https://github.com/git/git/blob/master/grep.c > > At the moment, it's not possible to use git grep very well outside of git > repositories. There are some issues around absolute and relative paths, > plus "git working directory". > > Eventually, I settled on writing a crude shell script that wraps GNU grep > to provide similar functionality. However, I am aware of its inefficiency, > as it requires multiple invocations of grep. > > Are people aware of this very cool grep feature with boolean logic? I > tried to search the GNU grep message archive, but I didn't see any > discussion about it. I'm curious what the GNU grep team thinks about this > feature. > > Kind regards, > Kevin Arpe > Hongkong From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 28 12:39:07 2021 Received: (at control) by debbugs.gnu.org; 28 Dec 2021 17:39:07 +0000 Received: from localhost ([127.0.0.1]:47334 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2GRH-0003wc-5h for submit@debbugs.gnu.org; Tue, 28 Dec 2021 12:39:07 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:43344) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2GRE-0003w7-Sf for control@debbugs.gnu.org; Tue, 28 Dec 2021 12:39:05 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id ED93B1600BC for ; Tue, 28 Dec 2021 09:38:57 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id nBUxk7QxP2N2 for ; Tue, 28 Dec 2021 09:38:57 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 5E337160137 for ; Tue, 28 Dec 2021 09:38:57 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 61ovFYfZYm9S for ; Tue, 28 Dec 2021 09:38:57 -0800 (PST) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 3F4801600BC for ; Tue, 28 Dec 2021 09:38:57 -0800 (PST) Message-ID: Date: Tue, 28 Dec 2021 09:38:56 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1 Content-Language: en-US To: control@debbugs.gnu.org From: Paul Eggert Subject: 52851 is wishlist Organization: UCLA Computer Science Department Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) severity 52851 wishlist