Skip to content

Conversation

@Tieske
Copy link
Member

@Tieske Tieske commented Mar 14, 2023

Some underlying methods, traversing files in directories and/or recursive functions suffer from the same problem.

Some underlying methods, traversing files in directories and/or
recursive functions suffer from the same problem.
@Tieske
Copy link
Member Author

Tieske commented Mar 14, 2023

this function;

local function filemask(mask)
    mask = utils.escape(path.normcase(mask))
    return '^'..mask:gsub('%%%*','.*'):gsub('%%%?','.')..'$'
end

creates the pattern for matching. It has a start-anchor so the old code would only match if the pattern included "*".

eg. "*.lua would match "/some/path/myfile.lua".
But "my*.lua" would not match "/some/path/myfile.lua".

so instead of using ".*" and "." as patterns, we should probably change to "[^/\\]*" and "[^/\\]" .

See https://en.wikipedia.org/wiki/Glob_(programming), which explicitly names fnmatch as the common interface, so that clearly gives the intent of the function.

@Tieske
Copy link
Member Author

Tieske commented Mar 14, 2023

looking at python; https://docs.python.org/3/library/fnmatch.html it mentions "Note that the filename separator ('/' on Unix) is not special to this module."

Which seems consistent with the existing implementation, yet makes for a bad user experience imho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants