Alternate glob matcher for .bzrignore
Jan Hudec
bulb at ucw.cz
Mon Jan 9 13:05:33 GMT 2006
On Mon, Jan 09, 2006 at 10:28:57 +0100, Harald Meland wrote:
> [Martin Pool]
>
> > It may be a bit surprising that '**.tmp' doesn't match .tmp within
> > directories, and you need '**/*.tmp'.
>
> Actually, I think you would have to set GLOB_DOTS in order for zsh to
> generate 'subdir/.tmp' from the pattern '**/*.tmp'.
>
> If GLOB_DOTS is not set, neither '*' nor '**' matches the leading '.'
> in a filename; this has to be explicitly included in the pattern.
>
> (All this is according to the description in zshexpn(1).)
>
> Here are some possible glob-to-regex translations:
>
> Glob Regex Comment
> * .* Matches leading '.'
> Matches multiple path components
>
> * [^/]* Matches leading '.'
> Matches only single path component
>
> * ((?<=(^|/))[^./][^/]*|(?<!(^|/))[^/]*)
> Doesn't match leading '.'
> Matches only single path component
>
> ** .* Matches leading '.'
> Can match on part of a path component
> Matches both files and directories
>
> ** ((?<=(^|/)).*/|(?<!(^|/))[^/]*)
> Matches leading '.'
> Will match at most a single path component
> unless the glob is found at the start of a
> path component; however, '**foo' will match
> e.g. 'bar/foo'.
> Can match on part of a path component
> Matches both files and directories
>
> In all the above cases the special directories '.' and '..' will be
> matched by the regexp, and hence have to be removed from the result
> set by other means.
>
> I think the '**' glob, as described in zshexpn(1), is quite hard (or
> maybe even impossible) to properly translate into a regexp. In
> particular, it's hard to have it only match on directories (unless
> bzrlib can guarantee that all candidate directories will have a
> trailing / when passed to the glob expander).
Sure it is possible. But you have to translate **/, not **! Then it is
(if I got it correctly):
((?<=(^|/))([^./][^/]*/)*)
(the empty-string case omitted, because components can't be empty.
--
Jan 'Bulb' Hudec <bulb at ucw.cz>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060109/fede5f9c/attachment.pgp
More information about the bazaar
mailing list