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, T_SCC_BODY_TEXT_LINE 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 635CC28685 for ; Mon, 12 Feb 2024 22:53:36 +0100 (CET) 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:Cc:To:From:Date:References:In-Reply-To:Message-Id: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=XsA8/Yh6pODesJqgTcv5qbMsYeepYxvr9XcvBBgW+sU=; b=JEgDq8r/ryedEyHDlPhxfx+rJb 98hb0rwdcm9OjNqn5VMuZxcdHL2hW113H7ihHJiQ4UpAiHcTmP9JuYB81+PLHF5a5mOgNDg59cH+Y TBIkRS5/joZy0/SNqT7Vt+TqZBXPLe16fqfkv9BaM7sAoLaf6lpW5telYSaRL8r4pKBLU9GvAS4dj U0OfJqtbbJxJlyLTh/0fmU1Mc1A0GvIvp9+dNu9xzi1nIiFdJvWcZA4VA7hoFYVbr5itqxagxosvs eoaj663ezIchS7ZiWTUj6pvIIhcSU17yK+6t99kzvZZrbXXJuzvVMFepEuS/TNEkqpFxjis9lIVhl sckcJeXg==; Received: by zero.zsh.org with local id 1rZeF4-0002KP-36; Mon, 12 Feb 2024 21:53:34 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rZeEI-0001ee-Hj; Mon, 12 Feb 2024 21:52:47 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id EB42B27C0061; Mon, 12 Feb 2024 16:52:43 -0500 (EST) Received: from imap48 ([10.202.2.98]) by compute2.internal (MEProxy); Mon, 12 Feb 2024 16:52:43 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefgdduhedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtgfesthhqredtreerjeenucfhrhhomhepnfgr fihrvghntggvucggvghljoiiqhhuvgiiuceolhgrrhhrhihvseiishhhrdhorhhgqeenuc ggtffrrghtthgvrhhnpedvteekleeiheevvdetudehkedthedtjeegheejledufeeuffdu ueeggeejhfffffenucffohhmrghinhepshhouhhrtggvfhhorhhgvgdrihhonecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhihvodhm vghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduudehudekjeejtdegqdduudelvd ejfeekhedqlhgrrhhrhihvpeepiihshhdrohhrghesfhgrshhtmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: iaa214773:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id A12AD31A0065; Mon, 12 Feb 2024 16:52:43 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-144-ge5821d614e-fm-20240125.002-ge5821d61 MIME-Version: 1.0 Message-Id: <4521f970-04dd-4521-a450-44c365adf625@app.fastmail.com> In-Reply-To: References: <49716226-f212-491a-94d9-cfdb83b38aab@bashsupport.com> Date: Mon, 12 Feb 2024 16:50:51 -0500 From: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= To: "Mark J. Reed" , "Joachim Ansorg" Cc: zsh-users@zsh.org Subject: Re: Is ":G" of ${name:s/l/r/:G} actually supported? Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 29662 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 Mon, Feb 12, 2024, at 12:11 PM, Mark J. Reed wrote: > Well, that was a shorter reply than I intended. But you should be able=20 > to see that the section you linked (14.1.4 Modifiers) is part of 14.1,=20 > History Expansion. Those modifiers don't apply to parameter=20 > substitution. They do. % var=3Dfoobar % print -- $var:s/o/x fxobar This is documented in zshexpn(1) under "Modifiers": After the optional word designator, you can add a sequence of one or more of the following modifiers, each preceded by a `:'. These modifiers also work on the result of _filename generation_ and _parameter expansion_, except where noted. and "PARAMETER EXPANSION": In addition to the following operations, the colon modifiers described in the section `Modifiers' in the section `History Expansion' can be applied: for example, ${i:s/foo/bar/} performs string substitution on the expansion of parameter $i. > For doing replacements with parameter expansion, you can just use the=20 > slash modifier. One / replaces the first occurrence, two //s does all=20 > of them: > >> *$ value=3D/dir/subdir/file.csv* >> *$ echo ${value//dir/_G}* >> */_G/sub_G/file.csv* >=20 > That's not a zsh-specific feature; ksh and bash have it as well. Zsh=20 > likely has a different mechanism to accomplish the same thing, but I'v= e=20 > not needed it so am not familiar with it. The :s and :gs history modifiers are similar but not exactly so. Among other things, they perform literal searches by default, allow referring to the matched text with "&", and apply nested expansions differently. >> On Mon, Feb 12, 2024 at 9:19=E2=80=AFAM Joachim Ansorg wrote: >>> Hi, >>> I was reading about modifiers on page=20 >>> https://zsh.sourceforge.io/Doc/Release/Expansion.html#Modifiers, whi= ch says: >>>=20 >>> > The forms =E2=80=98gs/l/r=E2=80=99 and =E2=80=98s/l/r/:G=E2=80=99= perform global substitution, i.e. substitute every occurrence of r for = l. Note that the g or :G must appear in exactly the position shown. >>>=20 >>> But zsh 5.9 doesn't seem to support this: >>> > value=3D"/dir/subdir/file.csv" >>> > echo ${value:s/dir/_/:G} >>> zsh: unrecognized modifier `G' It doesn't work on zsh 4.3.11 either, which means it hasn't worked for at least 13 years. (This probably says something about the prevalence of applying :s/l/r/:G to parameter expansions.) >>> Is ":G" actually supported or is the documentation outdated here? I can't say for sure, but this feels like a bug to me. --=20 vq