Deewiant / glob

Haskell library for glob matching
https://deewiant.iki.fi/projects/glob/
Other
25 stars 8 forks source link

Repeated slashes with AnyDirectory wildcards #16

Closed hdgarrood closed 7 years ago

hdgarrood commented 7 years ago

Spotted in #12, see https://github.com/Deewiant/glob/pull/12#discussion_r136553246.

Running the following in ghci in the root directory of this project produces the following:

> globDir1 (compile "**//*.hs") "System"
["System/FilePath//Glob.hs","System/FilePath//Glob/Utils.hs","System/FilePath//Glob/Match.hs","System/FilePath//Glob/Directory.hs","System/FilePath//Glob/Simplify.hs","System/FilePath//Glob/Primitive.hs","System/FilePath//Glob/Base.hs"]

However, the repeated slashes should occur as the last directory separators, e.g. we should have "System/FilePath/Glob//Utils.hs" in the list, not "System/FilePath//Glob/Utils.hs".

@Deewiant notes that:

The incorrect slashing is in matchTypedAndGo, on line 205 here:

           True | isDir  -> do
              contents <- getRecursiveContents
                             (absPath ++ replicate n pathSeparator)

Replicating the path separators here is incorrect: it should happen at the deepest level of getRecursiveContents, not the first. I'm not sure if that can be done in a non-awkward fashion, though...