zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Cc: Alan Wagner-Krankel <awk@awkwork.com>
Subject: Re: Inconsistent behavior with comparisons and recursive glob patterns
Date: Tue, 30 Apr 2024 13:08:52 -0700	[thread overview]
Message-ID: <CAH+w=7Zp3uXAD6uP+gryphWFVqhhg1EDHioJCNqu5e0Mr6e5LA@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7YcdDM6enW37=j3LvOaBnPvazvE9DcHKiJ7VSz-zF7SgQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 569 bytes --]

(Moved from -users)

On Tue, Apr 30, 2024 at 11:15 AM Bart Schaefer
<schaefer@brasslantern.com> wrote:
>
> I suspect there's no explicit reasoning in zmv.  **/ is specifically
> handled in the case of zmv -w/-W (workers/27247) but not for '$f'
> placeholders.
>
> It works if you do this:
>
> zmv -n '(**/)f?' '$f.txt'
>
> Whether it should also work without the parens and also without the -w
> option is unclear.

Attached patch makes it work without the parens.  Is this within spec?
 It's hard to tell from the solitary '$f' example in the doc.

[-- Attachment #2: zmv-recur.txt --]
[-- Type: text/plain, Size: 871 bytes --]

diff --git a/Functions/Misc/zmv b/Functions/Misc/zmv
index 5c03e9ea1..2002af5a6 100644
--- a/Functions/Misc/zmv
+++ b/Functions/Misc/zmv
@@ -249,13 +249,13 @@ errs=()
 (( ${#files} )) || errs=( "no files matched \`$fpat'" )
 
 for f in $files; do
-  if [[ $pat = (#b)(*)\(\*\*##/\)(*) ]]; then
+  if [[ $pat = (#b)(*)(\(\*\*##/\)|\*\*##/)(*) ]]; then
     # This looks like a recursive glob.  This isn't good enough,
-    # because we should really enforce that $match[1] and $match[2]
+    # because we should really enforce that $match[1] and $match[3]
     # don't match slashes unless they were explicitly given.  But
     # it's a start.  It's fine for the classic case where (**/) is
     # at the start of the pattern.
-    pat="$match[1](*/|)$match[2]"
+    pat="$match[1](*/|)$match[3]"
   fi
   [[ -e $f && $f = (#b)${~pat} ]] || continue
   set -- "$match[@]"

       reply	other threads:[~2024-04-30 20:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAGZNKjL2cJhLopFPAFFTewh2cHxX+_L4vMx2Nf9bAS0ud58RBw@mail.gmail.com>
     [not found] ` <c97c8fe9-2f56-45b7-bfb2-9f2a97283859@gmx.com>
     [not found]   ` <CAH+w=7YcdDM6enW37=j3LvOaBnPvazvE9DcHKiJ7VSz-zF7SgQ@mail.gmail.com>
2024-04-30 20:08     ` Bart Schaefer [this message]
2024-05-05  6:29       ` Alan Wagner-Krankel
2024-05-01  7:55   ` Alan Wagner-Krankel
2024-05-01  8:38     ` Peter Stephenson
2024-05-05  6:33       ` Alan Wagner-Krankel
2024-05-07 15:08         ` Peter Stephenson
2024-05-08  5:59           ` Alan Wagner-Krankel

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='CAH+w=7Zp3uXAD6uP+gryphWFVqhhg1EDHioJCNqu5e0Mr6e5LA@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=awk@awkwork.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).