From: Stephane Chazelas <stephane@chazelas.org>
To: Peter Stephenson <p.w.stephenson@ntlworld.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: histsubstpattern in zmv
Date: Fri, 2 Jun 2023 16:09:53 +0100 [thread overview]
Message-ID: <20230602150953.xr6ukng3oxsv2jpv@chazelas.org> (raw)
In-Reply-To: <1068343689.5141130.1685701118603@mail.virginmedia.com>
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
next prev parent reply other threads:[~2023-06-02 15:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-01 18:35 Stephane Chazelas
2023-06-02 8:40 ` Peter Stephenson
2023-06-02 10:18 ` Peter Stephenson
2023-06-02 15:09 ` Stephane Chazelas [this message]
2023-06-02 15:29 ` Stephane Chazelas
2023-06-04 18:32 ` Peter Stephenson
2023-06-08 6:57 ` Jun T
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230602150953.xr6ukng3oxsv2jpv@chazelas.org \
--to=stephane@chazelas.org \
--cc=p.w.stephenson@ntlworld.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).