Skip to content

globset: Default for literal_separator #2940

Answered by BurntSushi
mschoettle asked this question in Q&A
Discussion options

You must be logged in to vote

I followed glob's example.

And it's also how Python's fnmatch module works:

>>> import fnmatch
>>> fnmatch.fnmatch('foo/bar/demo.txt', '*.txt')
True

I don't think there is any one commonly accepted default. And it depends on context. For a crate like globset, it's common to pass a full path to it. And in that context, it's reasonable to expect that things like *.txt match foo/bar.txt. But in the context of something like glob(7), it's more common to execute a glob in the context of a single directory where you don't expect * to traverse into sub-directories.

To be honest, globbing is a bit of a mess. And like regex, pretty much all implementations have their own little quirks and features.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mschoettle
Comment options

Answer selected by BurntSushi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants