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

Re: How to overcome the (a/b/c…)(N) pattern limitation?



On Sat, Apr 18, 2020 at 4:24 PM Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> wrote:
>
> On Sat, 18 Apr 2020 at 22:00, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>>
>> In this case, "useful" collides directly with "practical" given the
>> semantics of "/" imposed by the underlying file system.
>
> What do you mean?

I mean that given a directory tree a/b/c/d/e/f, you can't do
opendir("a/b/c") and then get back "d/e/f" from readdir(), whereas
every other pattern can be compared directly against a value returned
by readdir().

>  it puzzled me that such /-using patterns aren't allowed. Mikachu has a patch allowing them, maybe it's worth adding it to the upstream?:
>
> http://comm.it.cx/cgit/zsh-cvs/commit/?h=mika&id=512bd3f23ea8b4170d88582521d417cdb247413a

I don't think that actually does what you want.  This works:

% setopt jankypatterns
% ls -d (Completion/Base/Core|Completion/X/Type)
Completion/Base/Core    Completion/X/Type

But this doesn't:

% ls -d */(Base/Core|X/Type)
zsh: bad pattern: */(Base/Core|X/Type)
% ls -d (*/(Base/Core|X/Type))
zsh: no matches found: (*/(Base/Core|X/Type))

The latter failures are why Mikachu's patch is not presently suitable
for inclusion upstream.



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