-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Brittany strips shebangs #192
Comments
I think this is related to #92. I tried using both STDIN and a file; both worked. Can you try again and reopen this if it's still a problem? Thanks! |
I think this has regressed, specifically on usage with a file: % stack exec brittany -- --version
brittany version 0.12.0.0
Copyright (C) 2016-2018 Lennart Spitzner
There is NO WARRANTY, to the extent permitted by law.
% stack exec brittany < ./scripts/hello
#!/usr/bin/env stack
-- stack script --resolver lts-15.4
-- vim: ft=haskell
module Main
( main
)
where
main :: IO ()
main = putStrLn "Hello"
% stack exec brittany ./scripts/hello
-- stack script --resolver lts-15.4
-- vim: ft=haskell
module Main
( main
)
where
main :: IO ()
main = putStrLn "Hello" Can we re-open? |
Seems like this has been fixed again: # cat issue-192.hs
#! /usr/bin/env stack
-- stack --resolver lts-16.0 script
main = pure ()
# brittany issue-192.hs
#! /usr/bin/env stack
-- stack --resolver lts-16.0 script
main = pure ()
# brittany --version
brittany version 0.12.1.1
Copyright (C) 2016-2019 Lennart Spitzner
Copyright (C) 2019 PRODA LTD
There is NO WARRANTY, to the extent permitted by law. |
Nice, thanks! |
👋 It's me again... This bug seems to still occur, but only if you invoke it with a certain kind of path. % cat issue-192.hs
#!/usr/bin/env stack
-- stack --resolver lts-16.0 script
main = pure ()
% stack exec brittany -- --version
brittany version 0.12.1.1
Copyright (C) 2016-2019 Lennart Spitzner
Copyright (C) 2019 PRODA LTD
There is NO WARRANTY, to the extent permitted by law. % stack exec brittany -- issue-192.hs
#!/usr/bin/env stack
-- stack --resolver lts-16.0 script
main = pure ()
% stack exec brittany -- ./issue-192.hs
-- stack --resolver lts-16.0 script#!/usr/bin/env stack
main = pure () So, The bug also triggers on absolute paths or relative paths outside the current directory, but only if you % stack exec brittany -- x/issue-192.hs
#!/usr/bin/env stack
-- stack --resolver lts-16.0 script
main = pure ()
% stack exec brittany -- ./x/issue-192.hs
-- stack --resolver lts-16.0 script#!/usr/bin/env stack
main = pure () % stack exec brittany -- ../../brittany-repro/issue-192.hs
-- stack --resolver lts-16.0 script#!/usr/bin/env stack
main = pure ()
🤷 My editor plugin (ALE in vim) uses an absolute path to a tempfile, which is why the bug bites me so frequently. |
Oh dear. That's super weird. |
FYI, this seems to be the root cause: alanz/ghc-exactprint#92 I got bit in HLint too (via apply-refact, via ghc-exact-print, which I believe Brittany uses as well). |
This has been fixed. |
Example
/tmp/script
Expected
(Shebang preserved.)
Actual
(The shebang was stripped.)
This makes brittany unusable for so-called "Stack Scripts", which are becoming quite popular.
The text was updated successfully, but these errors were encountered: