Alternate glob matcher for .bzrignore
Harald Meland
harald.meland at usit.uio.no
Mon Jan 9 09:28:57 GMT 2006
[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).
--
Harald
More information about the bazaar
mailing list