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 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?


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.

> 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?

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)
)



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