Skip to content

Commit cb36882

Browse files
Restore the static prefix to glob matches. Oops.
1 parent 1b0da19 commit cb36882

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Cabal/Distribution/Simple/Glob.hs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import Distribution.Simple.Utils
3030
import Distribution.Verbosity
3131
import Distribution.Version
3232

33-
import System.FilePath (joinPath, splitExtensions, splitPath, takeExtensions)
33+
import System.FilePath (joinPath, splitExtensions, splitPath, takeExtensions, (</>))
3434

3535
data GlobSyntaxError
3636
= StarInDirectory
@@ -135,6 +135,7 @@ parseFileGlob version filepath = case reverse (splitPath filepath) of
135135
matchFileGlob :: Verbosity -> Version -> FilePath -> IO [FilePath]
136136
matchFileGlob verbosity version = matchDirFileGlob verbosity version "."
137137

138+
-- The returned values do not include the supplied @dir@ prefix.
138139
matchDirFileGlob :: Verbosity -> Version -> FilePath -> FilePath -> IO [FilePath]
139140
matchDirFileGlob 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

157159
unfoldr' :: (a -> Either r (b, a)) -> a -> ([b], r)
158160
unfoldr' f a = case f a of

0 commit comments

Comments
 (0)