zsh-users
 help / color / mirror / code / Atom feed
From: ZyX <kp-pav@yandex.ru>
To: Mikael Magnusson <mikachu@gmail.com>,
	"vogt@linux.vnet.ibm.com" <vogt@linux.vnet.ibm.com>,
	Zsh Users <zsh-users@zsh.org>
Subject: Re: Recursive globbing shorthand (a la **.c)
Date: Wed, 28 Oct 2015 22:04:04 +0300	[thread overview]
Message-ID: <240121446059044@web30h.yandex.ru> (raw)
In-Reply-To: <CAHYJk3TjmMEYZ-j5VT=D4WDPtZZkFVzKNXzYw9vxZReC0o-FZg@mail.gmail.com>

28.10.2015, 16:28, "Mikael Magnusson" <mikachu@gmail.com>:
> On Wed, Oct 28, 2015 at 7:57 AM, Dominik Vogt <vogt@linux.vnet.ibm.com> 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


  reply	other threads:[~2015-10-28 19:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-28  6:57 Dominik Vogt
2015-10-28 13:27 ` Mikael Magnusson
2015-10-28 19:04   ` ZyX [this message]
     [not found]   ` <240121446059044__35603.2418822453$1446059490$gmane$org@web30h.yandex.ru>
2015-10-28 21:15     ` Stephane Chazelas
2015-10-29 10:15   ` Dominik Vogt
2015-10-29 10:53 ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=240121446059044@web30h.yandex.ru \
    --to=kp-pav@yandex.ru \
    --cc=mikachu@gmail.com \
    --cc=vogt@linux.vnet.ibm.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).