@@ -30,7 +30,7 @@ import Distribution.Simple.Utils
3030import Distribution.Verbosity
3131import Distribution.Version
3232
33- import System.FilePath (joinPath , splitExtensions , splitPath , takeExtensions )
33+ import System.FilePath (joinPath , splitExtensions , splitPath , takeExtensions , (</>) )
3434
3535data GlobSyntaxError
3636 = StarInDirectory
@@ -135,6 +135,7 @@ parseFileGlob version filepath = case reverse (splitPath filepath) of
135135matchFileGlob :: Verbosity -> Version -> FilePath -> IO [FilePath ]
136136matchFileGlob verbosity version = matchDirFileGlob verbosity version " ."
137137
138+ -- The returned values do not include the supplied @dir@ prefix.
138139matchDirFileGlob :: Verbosity -> Version -> FilePath -> FilePath -> IO [FilePath ]
139140matchDirFileGlob verbosity version dir filepath = case parseFileGlob version filepath of
140141 Left err -> die' verbosity $ explainGlobSyntaxError filepath err
@@ -146,13 +147,14 @@ matchDirFileGlob verbosity version dir filepath = case parseFileGlob version fil
146147 -- there. If the pattern is **/*.blah, then of course we'll have
147148 -- to walk the whole thing anyway, but that's what the user asked
148149 -- for!
149- let (prefix, pat') = splitConstantPrefix pat
150- files <- getDirectoryContentsRecursive $ joinPath (dir : prefix)
150+ let (prefixSegments, pat') = splitConstantPrefix pat
151+ joinedPrefix = joinPath prefixSegments
152+ files <- getDirectoryContentsRecursive (dir </> joinedPrefix)
151153 case filter (fileGlobMatches pat') files of
152154 [] -> die' verbosity $
153155 " filepath wildcard '" ++ filepath
154156 ++ " ' does not match any files."
155- matches -> return matches
157+ matches -> return $ fmap (joinedPrefix </> ) matches
156158
157159unfoldr' :: (a -> Either r (b , a )) -> a -> ([b ], r )
158160unfoldr' f a = case f a of
0 commit comments