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

Re: Is this a bug?



On 4/19/22, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Tue, Apr 19, 2022 at 10:13 AM Mikael Magnusson <mikachu@xxxxxxxxx>
> wrote:
>>
>> Hmm?
>> % mkdir -p {a,Volumes}/{b,Volumes}/{c,Volumes}
>> % print -l ((^Volumes)/)#
>> a/
>> a/b/
>> a/b/c/
>
> Sure, but try ((^Volumes)/)#/ and suddenly you're recursing from the root.

There's no reason to append this extra slash, (foo/)#hello works fine
to match bar/hello (but not /hello).

% touch a/b/c/hello
% print -l ((^Volumes)/)#hello
a/b/c/hello


> For Perry's specific use case, ./((^Volumes)/)#/ is OK, because he
> only cares about directories, bad things can happen if you end that
> with another glob.  I discounted ./((^Volumes)/)#/(^Volumes) but
> that's because it runs afoul of bare_glob_qual, it works if you unset
> that or append some other qualifier to force (^...) to be taken as a
> pattern.

Afaict, ((^Volumes)/)#^Volumes should work fine there.

% touch **/*(/e*'REPLY+=/bar'*)
% print -l ((^Volumes)/)#^Volumes
a
a/b
a/b/bar
a/b/c
a/b/c/bar
a/b/c/hello
a/bar


-- 
Mikael Magnusson




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