runghc screws up terminal buffering mode and doesn't reset it
If I use runghc to run a Haskell script that reads from stdin, my terminal gets put into a strange buffering mode. This makes the script essentially unusable: characters are echoed twice, and Backspace and EOF don't work. The state is not even reset afterwards, so future non-Haskell programs act strangely as well.
$ cat cat.hs
main = putStr =<< getContents
$ stty
speed 38400 baud; line = 0;
eol = M-^?; eol2 = M-^?; swtch = M-^?;
iutf8
$ runghc cat.hs
hheelllloo
^D^?^D^D^C
cat.hs: exception :: GhcException
$ stty
speed 38400 baud; line = 0;
eol = M-^?; eol2 = M-^?; swtch = M-^?; min = 1; time = 0;
iutf8
-icanon
There is no problem if the script is compiled with ghc instead of interpreted with runghc.
I'm using ghc 6.8.2-2ubuntu1 on hardy amd64.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 6.8.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | GHCi |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | x86_64 (amd64) |