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:08 PM Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> wrote:
> pick="(/tmp/gh|./gh)"
> list=( ${(M)~pick##/*}(DN) )

I'll simplify:

  list=( $~pick )

This doesn't work because $pick contains slashes within parentheses.
This isn't allowed in file generation (with one exception). From the


  Matches the enclosed pattern. [...]

  Note that grouping cannot extend over multiple directories: it is
  an error to have a ‘/’ within a group (this only applies for
  patterns used in filename generation). There is one exception: a
  group of the form (pat/)# appearing as a complete path segment can
  match a sequence of directories. For example, foo/(a*/)#bar matches
  foo/bar, foo/any/bar, foo/any/anyother/bar, and so on.

Also note that ##/* in your example is applied before file generation.
The effect of the complete example is thus equivalent to this:

  list=( ${~tmp}(DN) )


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