diff options
| author | zjncs <[email protected]> | 2026-09-04 15:12:12 +0800 |
|---|---|---|
| committer | zjncs <[email protected]> | 2026-09-04 15:12:12 +0800 |
| commit | 8102c104461c1bb71a13e4531c59e23e371d35be (patch) | |
| tree | 8f92b07a024f3de21639fe33d68dcb93a0f38369 /xmake/core/base/path.lua | |
| parent | c1a32b8b31bb78cf4ac4b51b0a7a08b6c4224505 (diff) | |
escape brackets in path.pattern
path.pattern() escapes the lua pattern magic characters except '[' and
']', so a filename containing brackets is treated as a character class.
For example, os.files("a[1]*.lua") matches "a1.lua" instead of
"a[1].lua", and remove_files("a[1].lua") would remove "a1.lua"
instead of "a[1].lua".
Escape '[' and ']' like the other magic characters so bracket
characters in file names are matched literally.
Diffstat (limited to 'xmake/core/base/path.lua')
| -rw-r--r-- | xmake/core/base/path.lua | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/xmake/core/base/path.lua b/xmake/core/base/path.lua index ee154147f..79317decf 100644 --- a/xmake/core/base/path.lua +++ b/xmake/core/base/path.lua @@ -442,7 +442,7 @@ end function path.pattern(pattern) -- translate wildcards, e.g. *, ** - pattern = pattern:gsub("([%+%.%-%^%$%(%)%%])", "%%%1") + pattern = pattern:gsub("([%+%.%-%^%$%(%)%%%[%]])", "%%%1") pattern = pattern:gsub("%*%*", "\001") pattern = pattern:gsub("%*", "\002") pattern = pattern:gsub("\001", ".*") |
