docs icon indicating copy to clipboard operation
docs copied to clipboard

Pattern Matching docs do not make sense?

Open shoce opened this issue 1 year ago • 7 comments

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.

shoce avatar Jan 17 '25 19:01 shoce

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.

ravindk89 avatar Jan 17 '25 20:01 ravindk89

See https://github.com/minio/pkg/blob/1a72a87db0b49a06a3171c960bc8287b0baa2e04/wildcard/match.go#L72

djwfyi avatar Jan 17 '25 21:01 djwfyi

@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.

ravindk89 avatar Jan 17 '25 22:01 ravindk89

@vadmeste @donatello ping on the above - do we have more specific guidance on how pattern matching should work for mc commands?

ravindk89 avatar Feb 20 '25 16:02 ravindk89

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 avatar Apr 01 '25 19:04 djwfyi

@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?

OrkhanAlikhanov avatar Apr 05 '25 18:04 OrkhanAlikhanov

It seems to just return true when 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.

shoce avatar Apr 06 '25 04:04 shoce