Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to overcome the (a/b/c…)(N) pattern limitation?
- X-seq: zsh-users 24794
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- Subject: Re: How to overcome the (a/b/c…)(N) pattern limitation?
- Date: Sat, 18 Apr 2020 16:31:19 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- In-reply-to: <CAKc7PVCDdMUaXYeW0yZU_Cnv=HbNR_w2tRxFcL-Ek3Zi8hvt-w@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVB3rrKq6xT58fK4m1Bs_LUkA5wMKGvM8-G_5aJaBe6xTg@mail.gmail.com> <CAN=4vMrEn-j3Y=mZcLOkPwN6Hbq-oLxJ8yXD9JwQKJadEbtmxQ@mail.gmail.com> <CAKc7PVCJfCwUUrm5KXzzehxuX1JF=Bvwkh=m7we_TiCrtw_fhQ@mail.gmail.com> <CAN=4vMp3+RqyoHi2ZUomxxMxS26KP_7fjrN5zVOeKfrhUSuecQ@mail.gmail.com> <CAKc7PVCDdMUaXYeW0yZU_Cnv=HbNR_w2tRxFcL-Ek3Zi8hvt-w@mail.gmail.com>
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:
pick="(/tmp/gh|./gh)"
list=( $~pick )
This doesn't work because $pick contains slashes within parentheses.
This isn't allowed in file generation (with one exception). From the
docs:
(...)
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:
pick="(/tmp/gh|./gh)"
tmp=${(M)pick##/*}
list=( ${~tmp}(DN) )
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author