Skip to content

Commit 49500a1

Browse files
committed
for 'stack ghci', don't throw away hsSourceDirs that have '..' in them. commercialhaskell#2895
1 parent c67b7f9 commit 49500a1

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/Path/Extra.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module Path.Extra
77
,dropRoot
88
,parseCollapsedAbsDir
99
,parseCollapsedAbsFile
10+
,concatAndColapseAbsDir
1011
,rejectMissingFile
1112
,rejectMissingDir
1213
,pathToByteString
@@ -43,6 +44,12 @@ parseCollapsedAbsDir = parseAbsDir . collapseFilePath
4344
parseCollapsedAbsFile :: MonadThrow m => FilePath -> m (Path Abs File)
4445
parseCollapsedAbsFile = parseAbsFile . collapseFilePath
4546

47+
-- | Combine a 'Path Abs Dir' and a relative 'FilePath' into a 'Path Abs Dir'
48+
-- We can't parse the FilePath first because we need to account for ".."
49+
-- in the FilePath (#2895)
50+
concatAndColapseAbsDir :: MonadThrow m => Path Abs Dir -> FilePath -> m (Path Abs Dir)
51+
concatAndColapseAbsDir base rel = parseCollapsedAbsDir (toFilePath base FP.</> rel)
52+
4653
-- | Collapse intermediate "." and ".." directories from a path.
4754
--
4855
-- > collapseFilePath "./foo" == "foo"

src/Stack/Package.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ generateBuildInfoOpts BioInput {..} =
420420
| Just makeGenDir <- [fileGenDirFromComponentName biComponentName]]) ++
421421
["-stubdir=" ++ toFilePathNoTrailingSep (buildDir biDistDir)]
422422
toIncludeDir "." = Just biCabalDir
423-
toIncludeDir x = fmap (biCabalDir </>) (parseRelDir x)
423+
toIncludeDir relDir = concatAndColapseAbsDir biCabalDir relDir
424424
includeOpts =
425425
map ("-I" <>) (configExtraIncludeDirs <> pkgIncludeOpts)
426426
configExtraIncludeDirs =

0 commit comments

Comments
 (0)