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

Re: Inconsistent behavior with comparisons and recursive glob patterns



On Tue, Apr 30, 2024 at 1:15 AM Alan Wagner-Krankel <awk@xxxxxxxxxxx> wrote:
>
> > zmv -n '**/f?' '$f.txt'
> mv -- d1/d2/f2 d1/d2/f2.txt
> mv -- d1/f1 d1/f1.txt
> > zmv -n '(*/)#f?' '$f.txt'
> mv -- d1/d2/f2 d1/d2/f2.txt
> mv -- d1/f1 d1/f1.txt
> mv -- f0 f0.txt
>
> I think both zmv calls should have attempted to update the 'f0' file
> in the base directory. Am I missing something?

On Tue, Apr 30, 2024 at 7:11 AM Eric Cook <llua@xxxxxxx> wrote:
>
> ```
> Pattern metacharacters are active for the pattern arguments; the patterns  are
> the  same  as those used for filename generation, see zshexpn(1), but there is
> no special behaviour of ‘/' nor initial dots, and no glob qualifiers  are  al‐
> lowed.
> ```
>
> I'll leave zmv's implementation for someone else to answer but i suspect the reasoning is similar.

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.




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