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, 18 Apr 2020 at 22:00, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
wrote:

> On Sat, Apr 18, 2020 at 5:51 AM Sebastian Gniazdowski
> <sgniazdowski@xxxxxxxxx> wrote:
> >
> > I was trying to do: ls (/tmp/somedir/gh|./gh)(N) to obtain the error
> > message:
> >
> > zsh: bad pattern: (/tmp/somedir/gh|./gh)(N)
>
> Just making sure you don't mean that you were trying to obtain the
> error message?  If you did mean that, what did you get instead?
>

No, I didn't want to obtain the error, so I guess that your first
impression was correct.


> On Sat, Apr 18, 2020 at 7:43 AM Sebastian Gniazdowski
> <sgniazdowski@xxxxxxxxx> wrote:
> >
> > Yes, but as I wrote, such patterns are useful, good ones and I'm looking
> > for an alternative form for them.
>
> In this case, "useful" collides directly with "practical" given the
> semantics of "/" imposed by the underlying file system.
>

What do you mean? In the big, complete picture the user installs a
binary-release, GitHub plugin. It can come either from a deb/rpm file or
from a tar.gz. If it comes from deb (selected when the system has
dpkg-deb), then the binary will be located in plugin-dir/usr/bin/gh, if
from tarball then in plugin-dir/gh. So to match the file with the pick
ice-mod – Zinit's (formerly Zplugin) tool to select the binary that should
be added to PATH – an alternative (usr/bin/gh|gh) comes to mind. The issue
has resolved by using **/gh, however 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


> > list=( ${(M)~ZINIT_ICE[pick]##/*}(DN)
> > $local_dir/$dirname/${~ZINIT_ICE[pick]##/*}(DN.) )
>
> I'm a little puzzled about what the contents of ZINIT_ICE[pick] look
> like.  Do you not want this to work for (.gh|/tmp/gh) as well as the
> reverse?
>

It can be either an absolute path, like "$ZPFX/bin/something" (where ZPFX
is ~/.zinit/polaris by default) or an pattern that'll be applied inside the
plugin directory.

If it's a simple list of alternatives without nested parens, you
> should be able to do this:
>
> list=(
> ${^~${(s:|:)ZINIT_ICE[pick]}//(#b)(#s)([^\/]*)/$local_dir\/$dirname\/$match(#q.)}(DN)
> )
>

Thanks, I'll think about extending pick''.
-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zinit
Blog: http://zdharma.org


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