Skip to content

RT#89596 -- add _globstar_ behavior #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

RT#89596 -- add _globstar_ behavior #10

wants to merge 1 commit into from

Conversation

mithun
Copy link

@mithun mithun commented Nov 12, 2016

@richardc
Copy link
Owner

The commit message needs to be rewritten. It's not sufficent to describe where you're copying the patch from, describe what the feature does, and why it does it the way that it does it.

However, if C<$Text::Glob::globstar> is set to a true value, two
consecutive asterisks (e.g. C<**.foo>) B<will> match C</>, though one
asterisk will not.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't really explain the behaviour that I should expect. Try adding samples of paths that will and won't match.

Copy link

@trwyant trwyant Nov 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent (and, I believe the functionality) of the patch was to allow something like 'foo' to match 'baz/burfle.foo'. Without it (or without turning it on) the second asterisk is redundant, and though 'burfle.foo' would still match, 'baz/burfle.foo' would not. Looking at it now I can imagine a further tweak to collapse consecutive slashes, so that, for example, '/usr//foo' would match any and all of '/usr/local/bin/foo', '/usr/bin/foo', or '/usr/foo'. I believe that with the patch as it now stands '/usr/**/foo' would match the first two but not the third.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at it now I can imagine a further tweak to collapse consecutive slashes

@trwyant I've added you as a collaborator to the "mithun/perl-text-glob" fork. Can you please assist with the change? I can then help document/cleanup/squash.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, I recently stumbled across this because I wanted to match file names like rsync does. (I had not heard about the feature being in bash before)

I was going to work out the patch that would allow foo/**/bar to match foo/bar, but it turned out to be a lot more complicated than I expected. First, bash doesn't actually allow ** to match a /, it allows it to match zero or more directories. If you create a file a/b/c.pm, echo a**.pm does not match it. It seems that any time double-star is not anchored to a directory separator or the end of the string, it acts like a normal single-star. Also, bash does not allow double-star to match hidden directories, so the implementation should probably respect $strict_leading_dot in its implementation of $globstar.

Meanwhile, I actually like the rsync version of ** better, which does match partial filenames at the same time as directories. (but it's not a big deal, since rsync ** can be represented with bash */**/* and get the same effect) So maybe the first question is whether we want something compatible with bash, or compatible with rsync?

Also I found a bug where {_,.}foo doesn't match .foo when strict-dot is in effect, which I was going to fix with the implementation of strict-dot-aware globstar.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For discussion, see my proposal at nrdvana@7f7bfb9

The text says "bash behavior" but my examples are actually showing rsync behavior. In order to become bach compatible, **.foo would need to instead be **/*.foo and would somewhat surprisingly be able to match the string bar.foo.

nrdvana referenced this pull request in nrdvana/perl-text-glob May 25, 2018
The globstar feature does not yet meet all these criteria, but
I wanted something to show for discussion about how it would work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants