From mboxrd@z Thu Jan 1 00:00:00 1970
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org
X-Spam-Level:
X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID,
DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,
T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4
Received: (qmail 9293 invoked from network); 2 Jun 2023 08:40:59 -0000
Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368)
by inbox.vuxu.org with ESMTPUTF8; 2 Jun 2023 08:40:59 -0000
ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1685695259;
b=c13DNaMpEteAN4in66usyeRMzU3TIXHuYaEeu0xHhG0pTtcDQzPxnhfG3iSZOcB2EYaKXMdbfA
7syJvA+9xoxSsqWZzHUuIZJlD1Hs5COpLT8v/oZbGXgS5xUxhtraqP48tWf0aEtZj7Wi12wKDp
zfq/8khPHjZvZEfNaZoH/2VWBcbx5oAlY2Dy+upRCd99GmMHEFJ3Qag6huGc0/y6tGpxNk/MqM
cyallvJ70QMdWuYCSPGOS3llvO2Y7kANUwSaZ0Z88Lc0GhfBpEVTgBfxq1eZ7hF1NigA1mDLy5
TM8j6b71qwkPD5Vhq/hur8hVPXAuudTnM44HpNwgSnG4YQ==;
ARC-Authentication-Results: i=1; zsh.org;
iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96;
dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256;
dmarc=pass header.from=ntlworld.com;
arc=none
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1685695259;
bh=ylkKsDSNyZwWWwIhZg4ZAdPj3DgCltCSySOEeU7+U/4=;
h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help:
List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:
References:In-Reply-To:Message-ID:To:From:Date:DKIM-Signature:
DKIM-Signature;
b=s1jeU1LXKVG4TqBiciKfBgZ2zaQpEExD25qXSPeUX3dckfQsgW5KqAuikyMejDRHmrGS7SJgN2
vzczNA78UDtNGiozGeHATDhZu2djR1JdkmBtyyyDpOg5AKb8xUuv7uPmurvcB7F51FTu50NfOA
Wq7Srt31scx+CEPghRhYicblDqy9k8WvH3fcEjwUT6m8oRlO/F0Q6DUUa0qwbFy/UFjI5jcF+a
rZpWAakPq7xjLNh0kEEfxQhdXLV8/D3h9dcn4FXqVFYD0of3bp7FvV82G4keC/5sOkD/6XKR+J
Tq6rMeow/xfhFhOrH4Z0QZm6rMv3P5EkalRqTiFOnmBdBg==;
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:MIME-Version:Subject:References:In-Reply-To:Message-ID:To:From:
Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From:
Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID;
bh=MS4Y2VX2V8pxMrbAsaXEtyt6pPojFtizs+TSJbco5gQ=; b=Ogg+fJkEbgQzH/Ny5bfl6r2nth
y97T6t6K2z2JE4AcaYNn+zZ/3+gqd7QrRGOeoXJx2pkl3gJ1jGJy6111g38cXZifjZhmgaH5Bodnq
bcxIzBGihmvQ0W6+rBg6H2TVtp+ydC8iLdrL1Ow+QybB4PgnSxFi9SKfoqmV68fkhvbUpCNVS3WXR
LW4k1VZwu4CgSBAeFbtEiHjJw+ZhZvPdir5cqsLtqHhZnZ6iqmtEYTW7thmfir25d9LV16Pjxbkoz
YzkGQ8GgLqZvqj7Jdx1EzlsyYfgoYRHqz7D1Ya3IGW6TExYtvvwpmMiotyQEpWc+pSN6hVgpsoat7
3sdYhDXw==;
Received: by zero.zsh.org with local
id 1q50LB-0008fX-IU;
Fri, 02 Jun 2023 08:40:57 +0000
Authentication-Results: zsh.org;
iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96;
dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256;
dmarc=pass header.from=ntlworld.com;
arc=none
Received: from smtpq1.tb.ukmail.iss.as9143.net ([212.54.57.96]:58328)
by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
id 1q50KZ-0008MW-J0;
Fri, 02 Jun 2023 08:40:21 +0000
Received: from [212.54.57.81] (helo=smtp2.tb.ukmail.iss.as9143.net)
by smtpq1.tb.ukmail.iss.as9143.net with esmtp (Exim 4.90_1)
(envelope-from
)
id 1q50KZ-0003qJ-Cj
for zsh-workers@zsh.org; Fri, 02 Jun 2023 10:40:19 +0200
Received: from oxbe12.tb.ukmail.iss.as9143.net ([172.25.160.143])
by smtp2.tb.ukmail.iss.as9143.net with ESMTP
id 50KZqSXRmwPce50KZq9zgo; Fri, 02 Jun 2023 10:40:19 +0200
X-Env-Mailfrom: p.w.stephenson@ntlworld.com
X-Env-Rcptto: zsh-workers@zsh.org
X-SourceIP: 172.25.160.143
X-CNFS-Analysis: v=2.4 cv=F+CRNItN c=1 sm=1 tr=0 ts=6479aaf3 cx=a_exe
a=pVlFXI3Q25jgZXAaIqG4JA==:117 a=1DWFKdCB1IcA:10 a=IkcTkHD0fZMA:10
a=N898d1J4AAAA:8 a=-_7tl7RjiPur_Gb-Y0UA:9 a=QEXdDO2ut3YA:10
a=75Kt_H3ikK-EkTT1woid:22 a=4OhKILdWXy8MGewZJRtY:22
X-Authenticated-Sender: p.w.stephenson@ntlworld.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com;
s=meg.feb2017; t=1685695219;
bh=ylkKsDSNyZwWWwIhZg4ZAdPj3DgCltCSySOEeU7+U/4=;
h=Date:From:To:In-Reply-To:References:Subject;
b=VmaK4vP96+P1gQkW+6tY713XtwxOVIH2jT48Dx4sHFWgcB3nDiYmjFZn/clm8wFMQ
dJoQTBBMy8FlOyoigbsMB7hi3hHj3U2ZccVmS/yKrcSW27bv7+fbHCv1Jshgx+xcjC
LUpSdMPgbg5UBHT95tKnEf8ZIlaXw2+T//Vfcqfpn0GYon9msKk//eCWbCK6nRzH05
2xzmxly0n6HPVKu8Slfyji+Td6epteDMnNK5c22iNsqMJAKZP6MuoPzsw6mg3jIZjF
HeL9iKYdhrzkZFW1bCHISMQLfOUggPAs5TMrsmIyEroPujewHH+eFw/9/dsKDWLWsv
8PsFJcDV4ZOlw==
Date: Fri, 2 Jun 2023 09:40:19 +0100 (BST)
From: Peter Stephenson
To: Zsh hackers list
Message-ID: <1452348325.5131636.1685695219291@mail.virginmedia.com>
In-Reply-To: <20230601183556.nl3zhv2kdxgj7x4d@chazelas.org>
References: <20230601183556.nl3zhv2kdxgj7x4d@chazelas.org>
Subject: Re: histsubstpattern in zmv
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Priority: 3
Importance: Normal
X-Mailer: Open-Xchange Mailer
X-Originating-IP: 147.161.224.167
X-Originating-Client: open-xchange-appsuite
X-CMAE-Envelope: MS4xfIQFVRcbz9M3f/Gh4PyJVMXiO9UJvKwwKrxyDcjLbag8RQ0CDExhWsBMmsZI5ZJMl+YBvEJjL1680GPs7Ly+NjyuoAXc9jh070IzK4QPmpIS/C8bFVw/
CVHUGxTfZ6n9KE1Oh5k2Yal7D7lHOiJ5jvZmiSI080rfk3NqJg/nb4f82c9TNnXW1a+3W2Tg0YbBqUE5irHqgcKxxFP/fmA8sfkFM7YKvjYIQ1kK7gqGTyD/
X-Seq: 51815
Archived-At:
X-Loop: zsh-workers@zsh.org
Errors-To: zsh-workers-owner@zsh.org
Precedence: list
Precedence: bulk
Sender: zsh-workers-request@zsh.org
X-no-archive: yes
List-Id:
List-Help: ,
List-Subscribe: ,
List-Unsubscribe: ,
List-Post:
List-Owner:
List-Archive:
On 01/06/2023 19:35 Stephane Chazelas wrote:
> The csh-style ${var:s/foo/bar} is often more legible and easy
> to cumulate than the Korn-style equivalent ${var/foo/bar}
>..
> But that needs set -o histsubstpattern and in zmv, emulate -LR
> zsh resets options.
>
> Would it be possibe to enable it in zmv along with extendedglob
> which is already enabled there, or if not allow the user to enable it,
> or maybe even better introduced some :+s/pattern/repl/
> :-s/string/repl/ or :S/pattern/replacement/ so we can use both
> at the same time, like ${f:gs/***/3-stars/:gS/???/any-3-chars} ?
I can't see any good reason not to enable it. The range of
likely cases where this would cause problems is rather limited ---
I'd probably instinctively quote pattern characters anyway. But
if anyone thinks we should consider something more sophisticated
we can.
pws
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index 96de5aa9b..60553210c 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -4618,12 +4618,16 @@ example(zmv '(*).lis' '$1.txt')
renames `tt(foo.lis)' to `tt(foo.txt)', `tt(my.old.stuff.lis)' to
`tt(my.old.stuff.txt)', and so on.
-The pattern is always treated as an tt(EXTENDED_GLOB) pattern. Any file
-whose name is not changed by the substitution is simply ignored. Any
-error (a substitution resulted in an empty string, two substitutions gave
-the same result, the destination was an existing regular file and tt(-f)
-was not given) causes the entire function to abort without doing
-anything.
+The pattern is always treated as an tt(EXTENDED_GLOB) pattern.
+Furthermore, the tt(HIST_SUBST_PATTERN) option is enabled in order
+to allow the use of patterns in history-style substituions, i.e.
+tt(${f:s/)var(pat)tt(/)var(rep)tt(/}).
+
+Any file whose name is not changed by the substitution is simply
+ignored. Any error (a substitution resulted in an empty string, two
+substitutions gave the same result, the destination was an existing
+regular file and tt(-f) was not given) causes the entire function to
+abort without doing anything.
In addition to pattern replacement, the variable tt($f) can be referred
to in the second (replacement) argument. This makes it possible to
diff --git a/Functions/Misc/zmv b/Functions/Misc/zmv
index 269fe5ba5..58b0327cb 100644
--- a/Functions/Misc/zmv
+++ b/Functions/Misc/zmv
@@ -123,7 +123,7 @@
# paranoiacs like the author will probably put them there anyway.
emulate -RL zsh
-setopt extendedglob
+setopt extendedglob histsubstpattern
local f g args match mbegin mend files action myname tmpf opt exec
local opt_f opt_i opt_n opt_q opt_Q opt_s opt_M opt_C opt_L