Skip to content

Commit 8585cca

Browse files
committed
Strip CRs in import lines
1 parent ecca2b0 commit 8585cca

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Bug fixes:
7676
* `stack upload` no longer reveals your password when you type it on
7777
MinTTY-based Windows shells, such as Cygwin and MSYS2.
7878
See [#3142](https://github.com/commercialhaskell/stack/issues/3142)
79+
* `stack script`'s import parser will now properly parse files that
80+
have Windows-style line endings (CRLF)
7981

8082

8183
## 1.4.0

src/Stack/Script.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,15 @@ loadModuleInfo name = do
266266

267267
parseImports :: ByteString -> (Set PackageName, Set ModuleName)
268268
parseImports =
269-
fold . mapMaybe parseLine . S8.lines
269+
fold . mapMaybe (parseLine . stripCR) . S8.lines
270270
where
271+
-- Remove any carriage return character present at the end, to
272+
-- support Windows-style line endings (CRLF)
273+
stripCR bs
274+
| S8.null bs = bs
275+
| S8.last bs == '\r' = S8.init bs
276+
| otherwise = bs
277+
271278
stripPrefix x y
272279
| x `S8.isPrefixOf` y = Just $ S8.drop (S8.length x) y
273280
| otherwise = Nothing

0 commit comments

Comments
 (0)