Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

zmv -W/-w in subdirs, possibly patch



Hi,

% ren */*.JPG */*.jpg
zmv:232: bad pattern: (*/)(*).JPG

--- a/Functions/Misc/zmv
+++ b/Functions/Misc/zmv
@@ -187,7 +187,7 @@ if [[ -n $opt_w || -n $opt_W ]]; then
   # Well, this seems to work.
   # The tricky bit is getting all forms of [...] correct, but as long
   # as we require inactive bits to be backslashed its not so bad.
-  find='(#m)((\*\*#/|[*?]|<[0-9]#-[0-9]#>|\[(^|)(\]|)(\[:[a-z]##:\]|\\?|[^\]])##\])\##|?\###)'
+  find='(#m)((\*\*#|[*?]|<[0-9]#-[0-9]#>|\[(^|)(\]|)(\[:[a-z]##:\]|\\?|[^\]])##\])\##|?\###)'
   tmp="${pat//${~find}/$[++cnt]}"
   if [[ $cnt = 0 ]]; then
     print -r -- "$myname: warning: no wildcards were found in search
pattern" >&2

%  ren */*.JPG */*.jpg
[the files are renamed successfully]

My question is: Why was the / there in the first place? Would the
above patch break any existing usecases?
(in case it is hard to spot, the patch removes the only / on the
line). If it does break some weird complex
pattern, maybe I would argue that you should not use -w then.

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author