haltcase / glob

Pure Nim library for matching file paths against Unix style glob patterns.
https://glob.bolingen.me
MIT License
61 stars 5 forks source link

crash when listGlob("a/b0.txt", includeDirs=true) (ie, when pattern corrsponds to a filename) #15

Closed timotheecour closed 6 years ago

timotheecour commented 6 years ago

/Users/timothee/git_clone/nim/timn/tests/t48_glob/test.nim(7) test /Users/timothee/.nimble_choosenim/pkgs/glob-0.7.0/glob.nim(293) listGlob /Users/timothee/.nimble_choosenim/pkgs/glob-0.7.0/glob.nim(198) maybeJoin /Users/timothee/.choosenim/toolchains/nim-#devel/lib/pure/ospaths.nim(435) isAbsolute /Users/timothee/.choosenim/toolchains/nim-#devel/lib/system.nim(2871) sysFatal Error: unhandled exception: index out of bounds [IndexError] Error: execution of an external program failed: './app '

haltcase commented 6 years ago

I can't reproduce this on Windows.

import src/glob

echo listGlob("src/glob.nim", includeDirs = true)
# -> @["src\\glob.nim"]
timotheecour commented 6 years ago

found the underlying reason: https://github.com/nim-lang/Nim/issues/8251 turns out there are 2 bugs:

haltcase commented 6 years ago

~Where is glob producing nil strings?~ ah, must be maybeJoin?

https://github.com/citycide/glob/blob/b6de2fd1a9eff022bc0006e565840f431cb99015/src/glob.nim#L197-L198

timotheecour commented 6 years ago

update: my fix for https://github.com/nim-lang/Nim/issues/8251 just got merged so now remaining issue is this "glob code should not give a nil/empty string in the 1st place"

timotheecour commented 6 years ago

@citycide this bug doesn't seem to occur anymore ; did your recent commits address this? if so we should close this

haltcase commented 6 years ago

Yeah this was taken care of in https://github.com/citycide/glob/commit/0cdb00f268fc45df4c9ba73269a5cf54f4a250ee. Thanks!