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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22366 invoked from network); 2 Jun 2023 15:10:14 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 2 Jun 2023 15:10:14 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1685718614; b=dcEZb33ow5xkZ0WothkC0gFTTCtWkG9Fw8Aff0/ir0TqaZs18tNhTNGPZzcGprLHo2MMbExqAp hWh8QvWZHDUB2cBCembi28R0iYWvvBh7yuHFmB+P3vDvsvaIiSzqXX6to9+SPSrZj61wo/AL0v rbt5CkxvORhj+TbfYSWq+NvZiUKcYrrLSPpNdf1R3bBD2uZlwCSbEs0iS9PJPYbWV4SCGty2WW CAZNGeCH9C1epxXzMmwKm6pewJsVWjv0EFPgmgDcAqH/GD0yd2y0qY/AnL84bVdy9y6b217BHf pv/9oych6EkLYaQ1x84Efa3/vlCFCCIcdGQ/xCx+U9e1kg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay7-d.mail.gandi.net) smtp.remote-ip=217.70.183.200; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1685718614; bh=cfubGvXTv9Adl4X+b7fVqO1YXy8MeRc8BBzr5tABRmE=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:DKIM-Signature; b=bu7kQ0e7yTXUNIgoOZXUDiC9iKZS2GiIsxSpUiqUOgWpOWaCQ/aPtlKOOhq1z2uQbw5SFp0Pmg ZfYMovhAoiLFvQMpTuzb31RiigZoiy8YTuqerJSLbF5keIf62+JHz/69rQdBQEeMDXQODNyWTf rftRV1AJj+E01TBxAwiu1qEP8rbDB+dCWQ7/yLlQdgFOUoSm1MDFPS1182vKPgzUfiHtKUQ8dl 4cOVZBGdNRKhXd9fb0mP8gBIUjuJS9cbbLmyfmwjqePCQkISvi7hxTq+vov6IqPNDzx4i1HoqG MVAIK+KoAlI5hc8oAvlZ1sej6W2L/5dpJCsDgzR0a45NFA==; 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:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=3Clpb4/K4+MUr7hHCHF4j6FtAqMRZhIALNsLIxn+CRs=; b=dJkDsGoigjiGKp5GTQvM1sCchh 5dxZ71Uz6Ip0q4nZceKFlLt3F96liO3fWMxLBvLRKlXMBx03tLnP32571KUPmVDXW8cVSEOXJ6Bmp k54GDu/nl8YDJ+K/7TffqREWUa8GLwh+LH6SgzIPvWMs0aZdSVcu6mZ4mPX5uMi73+aipHXh4ruV6 MONgzxuAMcxnFpN/voRCudJ2i3H7f0oAJyfbxp95QhzMF16DDV5DpdkTupB/GEwqwd4QBo4hg48lO 4JRF7nT5GoVQlrz31OjtpmWcoPb7qdVpDzHsX5GL0AJSwDsHg3XoZkSJQBdwJLiNXZHmiggQmeH0v sd/sNhMA==; Received: by zero.zsh.org with local id 1q56Ps-000IOF-Id; Fri, 02 Jun 2023 15:10:12 +0000 Authentication-Results: zsh.org; iprev=pass (relay7-d.mail.gandi.net) smtp.remote-ip=217.70.183.200; dmarc=none header.from=chazelas.org; arc=none Received: from relay7-d.mail.gandi.net ([217.70.183.200]:47649) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1q56Pb-000I6a-3f; Fri, 02 Jun 2023 15:09:58 +0000 X-GND-Sasl: stephane@chazelas.org X-GND-Sasl: stephane@chazelas.org Received: by mail.gandi.net (Postfix) with ESMTPSA id 06AF920007; Fri, 2 Jun 2023 15:09:53 +0000 (UTC) Date: Fri, 2 Jun 2023 16:09:53 +0100 From: Stephane Chazelas To: Peter Stephenson Cc: Zsh hackers list Subject: Re: histsubstpattern in zmv Message-ID: <20230602150953.xr6ukng3oxsv2jpv@chazelas.org> Mail-Followup-To: Peter Stephenson , Zsh hackers list References: <20230601183556.nl3zhv2kdxgj7x4d@chazelas.org> <1452348325.5131636.1685695219291@mail.virginmedia.com> <1068343689.5141130.1685701118603@mail.virginmedia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1068343689.5141130.1685701118603@mail.virginmedia.com> X-Seq: 51817 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: 2023-06-02 11:18:38 +0100, Peter Stephenson: [...] > > I can't see any good reason not to enable it. > > Having said that, adding an :S variant isn't particularly difficult > and is more widely useful. [...] Many thanks for that. I take it that supersedes the other patch and that histsubstpattern will not be enabled in zmv? I suppose that any time a new history modifier is introduced, there's a chance that it may break code that did $var:that-modifier before. Like echo $hard:SOFT here. grep -rP '\$\w+(\[[^]]*\])?:S' . in the source of zsh or oh-my-zsh didn't turn up anything, grep -rP '\$\w+(\[[^]]*\])?:(?![aAceghlpPqQrstux])\w' . For occurrences of $var:x or $var[...]:x where x is a word character that is not one of the currently defined modifiers turns up a few such as: ./Completion/Zsh/Command/_cd: alt+=( "path-directories-$elem:directory in $tmpcdpath[$elem]:_path_files -W 'tmpcdpath[$elem]' -/" ) ./Completion/Unix/Command/_subversion: ${args/(#b)(*--file*):arg:/$match[1]:file:_files} So if we were to add a "f" or "d" or "_" modifier today, it would break some zsh code supplied with zsh. May be worth applying the patch below today for future-proofing and a note in the manual that it's unwise to leave a parameter expansion un-braced if it's followed by a ":"? diff --git a/Completion/BSD/Command/_rcctl b/Completion/BSD/Command/_rcctl index 98e4f9846..457c3eb85 100644 --- a/Completion/BSD/Command/_rcctl +++ b/Completion/BSD/Command/_rcctl @@ -46,6 +46,6 @@ case $service in '*:argument:' ;; ${(~j:|:)actions}|disable|enable) - _arguments "*:service to $words[2]:_services" + _arguments "*:service to ${words[2]}:_services" ;; esac diff --git a/Completion/Unix/Command/_ant b/Completion/Unix/Command/_ant index 7401c7449..36c7c0e89 100644 --- a/Completion/Unix/Command/_ant +++ b/Completion/Unix/Command/_ant @@ -79,8 +79,8 @@ case $state in compset -P '*:' compset -S ':*' _alternative \ - "classpath:$state:_path_files -qS: -g '*.(jar|zip)(-.)'" \ - "classpath:$state:_path_files -r': ' -/" && ret=0 + "classpath:${state}:_path_files -qS: -g '*.(jar|zip)(-.)'" \ + "classpath:${state}:_path_files -r': ' -/" && ret=0 ;; property) if compset -P 1 '*='; then diff --git a/Completion/Unix/Command/_ffmpeg b/Completion/Unix/Command/_ffmpeg index 1329939cd..e5afdac4f 100644 --- a/Completion/Unix/Command/_ffmpeg +++ b/Completion/Unix/Command/_ffmpeg @@ -125,7 +125,7 @@ local -a _ffmpeg_argspecs lastopt_description=${lastopt_description//:/\\:} if [[ $example == filename ]]; then lastopt_takesargs=0 - lastopt+=":$lastopt_description:_files" + lastopt+=":${lastopt_description}:_files" elif [[ $lastopt == -[asv]pre ]]; then lastopt_takesargs=0 lastopt="*$lastopt" diff --git a/Completion/Unix/Command/_java b/Completion/Unix/Command/_java index ff6e82645..b2352df7b 100644 --- a/Completion/Unix/Command/_java +++ b/Completion/Unix/Command/_java @@ -438,8 +438,8 @@ classpath|sourcepath|bootstrapclasspath|docletpath) compset -P '*:' compset -S ':*' _alternative \ - "classpath:$state:_path_files -qS: -g '*.(jar|zip)(-.)'" \ - "classpath:$state:_path_files -r': ' -/" && return + "classpath:${state}:_path_files -qS: -g '*.(jar|zip)(-.)'" \ + "classpath:${state}:_path_files -r': ' -/" && return ;; extdirs) diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion index 9a0328dca..ccaf310fa 100644 --- a/Completion/Unix/Command/_subversion +++ b/Completion/Unix/Command/_subversion @@ -139,7 +139,7 @@ _svn () { ;; (commit) args=( - ${args/(#b)(*--file*):arg:/$match[1]:file:_files} + ${args/(#b)(*--file*):arg:/${match[1]}:file:_files} '*:file: _svn_modified "committable"' ) ;; @@ -189,7 +189,7 @@ _svn () { args=( ':propname:(svn:ignore svn:keywords svn:executable svn:eol-style svn:mime-type svn:externals svn:needs-lock svn:global-ignores svn:auto-props)' ':propval:->propset_propval' - ${args/(#b)(*--file*):arg:/$match[1]:file:_files} + ${args/(#b)(*--file*):arg:/${match[1]}:file:_files} '*:path or url: _alternative "files:file:_files" "urls:URL:_svn_urls"' ) ;; diff --git a/Completion/Zsh/Command/_cd b/Completion/Zsh/Command/_cd index 961d121e0..9ca846c8f 100644 --- a/Completion/Zsh/Command/_cd +++ b/Completion/Zsh/Command/_cd @@ -73,7 +73,7 @@ else if zstyle -t ":completion:${curcontext}:path-directories" separate-sections; then local elem for ((elem=1; elem <= $#tmpcdpath; elem++)); do - alt+=( "path-directories-$elem:directory in $tmpcdpath[$elem]:_path_files -W 'tmpcdpath[$elem]' -/" ) + alt+=( "path-directories-${elem}:directory in ${tmpcdpath[$elem]}:_path_files -W 'tmpcdpath[$elem]' -/" ) done else (( $#tmpcdpath )) && -- Stephane