Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Recursive globbing shorthand (a la **.c)
- X-seq: zsh-users 20846
- From: ZyX <kp-pav@xxxxxxxxx>
- To: Mikael Magnusson <mikachu@xxxxxxxxx>, "vogt@xxxxxxxxxxxxxxxxxx" <vogt@xxxxxxxxxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Recursive globbing shorthand (a la **.c)
- Date: Wed, 28 Oct 2015 22:04:04 +0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1446059045; bh=yiQW7gqyzIzwh4c72uO9E3AD8f7Xvx+PDi/WQhQNIhU=; h=From:To:In-Reply-To:References:Subject:Date; b=W0OuYCsTuTaJE6NydZKOUOhBZZOkCCIMRI9dCQKhE8hFRyCCAM8L198zcdm7V9Aiq KdSiwq2j3DJAB4M/CsYiniAVfstU/2fbZmsIZ9Y/G/hyDsHAzIeqX5WRO64B1TzmhR 1lXY/jviHQzbYjgKHVvCRGEfkf9v08TwVmokdfgk=
- In-reply-to: <CAHYJk3TjmMEYZ-j5VT=D4WDPtZZkFVzKNXzYw9vxZReC0o-FZg@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>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20151028065702.GA8236@linux.vnet.ibm.com> <CAHYJk3TjmMEYZ-j5VT=D4WDPtZZkFVzKNXzYw9vxZReC0o-FZg@mail.gmail.com>
28.10.2015, 16:28, "Mikael Magnusson" <mikachu@xxxxxxxxx>:
> On Wed, Oct 28, 2015 at 7:57 AM, Dominik Vogt <vogt@xxxxxxxxxxxxxxxxxx> wrote:
>> Most of the time, I use recursive globbing to find files of
>> certain types, e.g.
>>
>> $ ll **/*.c
>>
>> With the zsh here (4.3.17), recursive globbing works only
>> with a plain ** anyway (i.e. in "**x" and "x**" the ** works just
>> like a plain "*"). So, is it possible (or a useful future
>> feature) to make "**" imply a trailing "/*" if not with a trailing
>> pattern? Then we could type
>>
>> $ ll **.c
>>
>> as a shorthand, and the "traditional" uses would work without
>> change (e.g. **/*.c or **/foo).
>>
>> (Note that on German keyboards, "/" and "*" are very awkward to
>> type in a sequence because both need the left shift key held and
>> the keys for the right hand are very far apart, so this is really
>> a usability issue.)
>
> If this is something you do often, you can do
> alias -g '**.c=**/*.c'
>
> I don't think it's useful to implement generally though, there's no
> particular reason to assume the pattern following the **/ should start
> with a *
This depends on how you treat patterns. In mercurial `**` is treated as `.*` and `*` is treated as `[^/]*`, so pattern `a**b` matches file `a/c/b` (note. With such interpretation transforming foo** into foo*/**, **bar into **/*bar and foo**bar into foo*/**/*bar makes perfect sense. Though mercurial is using regexps on a list of files, not the real globbing, this behaviour is official and not an accident: there are patterns like `**.c` in examples. As OP said this is convenient in many cases.
// And git documentation officially says that only valid uses of `**` are `…/**`, `**/…` and `…/**/…`.
>
> --
> Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author