diff options
author | Vaibhav Sagar <vaibhavsagar@gmail.com> | 2017-08-23 22:19:51 +0800 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2017-08-23 16:19:51 +0200 |
commit | 3bfd8be6e1c6a5e90b1cdf9ee5723e93de26d409 (patch) | |
tree | ee569391fa3cfca664ecda5185f21c626b471985 /lib | |
parent | b9b5330e170a680a11fb3569b7533c27dfe6abf6 (diff) | |
download | stylish-haskell-3bfd8be6e1c6a5e90b1cdf9ee5723e93de26d409.tar.gz |
Remove shebang lines at the beginning of file
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Language/Haskell/Stylish/Parse.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/Language/Haskell/Stylish/Parse.hs b/lib/Language/Haskell/Stylish/Parse.hs index 724ebe2..01def63 100644 --- a/lib/Language/Haskell/Stylish/Parse.hs +++ b/lib/Language/Haskell/Stylish/Parse.hs @@ -44,11 +44,11 @@ unCpp = unlines . go False . lines -------------------------------------------------------------------------------- --- | Remove shebang from the first line +-- | Remove shebang lines unShebang :: String -> String -unShebang str - | "#!" `isPrefixOf` str = unlines $ ("" :) $ drop 1 $ lines str - | otherwise = str +unShebang str = + let (shebangs, other) = break (not . ("#!" `isPrefixOf`)) (lines str) in + unlines $ map (const "") shebangs ++ other -------------------------------------------------------------------------------- |