From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 8922121E9E for ; Wed, 3 Apr 2024 00:46:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Subject:To:From:Date:References:In-Reply-To:Message-Id: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=SUZO7qFrQjnzO6palCPIO3KR3OG3sBaFw9dbRJxlPuk=; b=XhKvDfd0T4BzHU/eA34ki5MAuI dOyAKuYoNz8tVekIDIzalsu2ldfWvZdrCojAuUGk5Co6D5+xaO+RFY1UWS185Pow51hBbDmuzx24x Grgma2H+YUAIXLWuQ0XZZpSq03oLWabuAdLtukycww5Eb8nA69+kWWiXToup2apgwHtfs+B0rm911 vlX1QF15tgO0RN2kpQryTN5C1rFAdq3i679x/mDmjxSt97qHRkzBdkQM2MZoaomclxPmOpWsNFYNs j3Lb2RSXzmgC1uYxU//2iaQZv1dS8XsQ2T7rEXBdPe/B00PdcHyW7sgCHxbK36eF7rVQheX1Hy3Pn ohOTgiJg==; Received: by zero.zsh.org with local id 1rrmty-0005yT-08; Tue, 02 Apr 2024 22:46:46 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rrmtH-0005HO-99; Tue, 02 Apr 2024 22:46:03 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfauth.nyi.internal (Postfix) with ESMTP id 7C1E51200032 for ; Tue, 2 Apr 2024 18:46:01 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute2.internal (MEProxy); Tue, 02 Apr 2024 18:46:01 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudeffedgudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtgfesth hqredtreerjeenucfhrhhomhepnfgrfihrvghntggvucggvghljoiiqhhuvgiiuceolhgr rhhrhihvseiishhhrdhorhhgqeenucggtffrrghtthgvrhhnpefgffeghfehjeegtdeitd evgeehgeehjeefffeffeefieeguedvtdegtdetudeufeenucevlhhushhtvghrufhiiigv pedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihvhdomhgvshhmthhprghuth hhphgvrhhsohhnrghlihhthidqudduhedukeejjedtgedqudduledvjeefkeehqdhlrghr rhihvheppeiishhhrdhorhhgsehfrghsthhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: iaa214773:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 20FA031A0065; Tue, 2 Apr 2024 18:46:01 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-333-gbfea15422e-fm-20240327.001-gbfea1542 MIME-Version: 1.0 Message-Id: <33cad64c-296c-4b70-b606-7a094b0a5a14@app.fastmail.com> In-Reply-To: References: <7318f96a-c6ff-426b-aa64-93b8ea6ee9c1@eastlink.ca> <85dd54c7-d221-4c19-b3f5-8d8d251529f2@app.fastmail.com> Date: Tue, 02 Apr 2024 18:45:40 -0400 From: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= To: zsh-users@zsh.org Subject: Re: egrep --color=always 'zsh\.' Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 29768 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Tue, Apr 2, 2024, at 4:53 PM, Ray Andrews wrote: > On 2024-04-02 13:14, Lawrence Vel=C3=A1zquez wrote: >> The issue is probably that you are using the same pattern for both "a= pt-file search" and egrep, but they don't interpret it in the >> same way. By default, "apt-file search" does a literal substring >> match, so "\." will match backslash-period. > Right, I know that, my code sample was too lazy. The only issue is=20 > with the egrep. The solution is to stop using egrep. >> The function as presented cannot actually work with regex arguments, >> so just switch to "grep -F" and avoid the escaping issues altogether.= If there's no way for the shell to handle it, then that's just what I'l= l do. If you're going to continue using "apt-file search $1" then it simply does not make sense for $1 to be a regex, and it follows that it does not make sense to use "egrep $1". Using "grep -F" removes the need to try slicing and dicing the argument at all. Don't use the shell to paper over bad design when you can just fix the design. > Still .... I'm almost sure I've had to deal with this before. IIRC ev= ery situation I've come up against has been handled by the right combina= tion of quotes and backslashes ... I think. It is easy to escape characters that are special to zsh itself. It is not so easy to escape characters that are special to POSIX extended regex. (The rules are hardly impossible to work out, but they're not straightforward either.) >> No, egrep does not need the quotes. >> % apt-file search zsh-theme | egrep --color=3Dalways zsh.=20 >> ... >> zsh-theme-powerlevel9k: /usr/share/powerlevel9k/powerlevel9k.zsh-theme >>=20 >> % apt-file search zsh-theme | egrep --color=3Dalways zsh\. >> ... >> zsh-theme-powerlevel9k: /usr/share/powerlevel9k/powerlevel9k.zsh-theme >>=20 >> % apt-file search zsh-theme | egrep --color=3Dalways 'zsh.' >> ... >> zsh-theme-powerlevel9k: /usr/share/powerlevel9k/powerlevel9k.zsh-theme These three commands are effectively identical; they invoke egrep with the pattern "zsh.". >> % apt-file search zsh-theme | egrep --color=3Dalways 'zsh\.' >> [ no match ] > > ... the dot is matching the dash -- or anything else -- unless I use: = 'zsh\.'=20 Yes, you have to quote properly to ensure that egrep receives the necessary "zsh\." argument -- just as with any other command. But egrep itself does not "need" the quotes; it does not see them at all. This command is uglier but works just as well: % apt-file search zsh-theme | egrep --color=3Dalways zsh\\. "Preserving" the quotes, as you considered in your first message, would in fact break the command. --=20 vq