Pattern Matching docs do not make sense?
Looking at the Pattern Matching docs https://github.com/minio/docs/blob/main/source/reference/minio-mc.rst#pattern-matching i barely can see the point.
Let's take the first example:
Pattern | Text | Match Result
abc* | ab | Match
it does not make sense to me, as the pattern starts with abc and the text is even shorter.
Another example from the docs:
Pattern | Text | Match Result
abc*c | abcd | Match
also confuses me a lot - the pattern ends with c and the text does not.
https://github.com/minio/docs/commit/6cae178c36b6bbeb4eb18dd5f11821aeb7927d66
hm - @djwfyi do you recall at all where the pattern matching stuff came from? Inclined to agree it looks wrong, but this looks like a table we would have pulled from elsewhere.
Either way seems fine to go through and clean it up, these should be similar to glob matching rules.
See https://github.com/minio/pkg/blob/1a72a87db0b49a06a3171c960bc8287b0baa2e04/wildcard/match.go#L72
@donatello this looks a few years old - if most of our pattern matching boils down to blob-style we can say that and ditch the table. Or if you can recall how this came about that might help.
@vadmeste @donatello ping on the above - do we have more specific guidance on how pattern matching should work for mc commands?
Per the code comment, the matching is a prefix matching, not a really a pattern matching. In the context of prefix matching the table makes more sense.
@djwfyi, not only that it, from the code: https://github.com/minio/pkg/blob/c57313ca813e24ac767d8783aef21f17b4270863/wildcard/match.go#L72-L99
It seems to just return true when reaching * without considering anything after it. How is that even useful?
It seems to just return
truewhen reaching*without considering anything after it. How is that even useful?
thank you for pointing this, i think this is the root of my confusion, now i understand why this pattern matches:
// | Pattern | Text | Match Result |
// ====================================
// | abc*c | abcd | True |
i never saw a pattern matching like this, the last c in the pattern is just not considered, and the docs are not clear about it.